问:怎么分页&&按条件&&按顺序&&姓名不重复查出数据?
答:其实就是行转列,那么,postgresql怎么进行转列呢,百度了下,大概有三种写法
写法1 group by + sum + case when
select name, sum(case when zbfm='年龄' then value else 0 end) as 年龄, sum(case when zbfm='身高' then value else 0 end) as 身高, sum(case when zbfm='体重' then value else 0 end) as 体重 from test group by name having name like '%1' and length(name)=4 order by 年龄 desc