专业做胶粘剂招聘网站,一起做网店网站打不开,龙岗网站建设公司哪家口碑好,wordpress可以做论坛吗1.需求说明#xff1a;
当查询出来的数据存在多条数据时#xff0c;想按照一定条件排序取出其中一条数据。
2.使用函数#xff1a; row_number() over( partition by 分组字段 order by 排序字段 desc#xff09; 3.示例#xff1a; --根据table_a中的pk_house#x…1.需求说明
当查询出来的数据存在多条数据时想按照一定条件排序取出其中一条数据。
2.使用函数 row_number() over( partition by 分组字段 order by 排序字段 desc 3.示例 --根据table_a中的pk_housepk_customer进行分组然后根据table_b.billdate进行排序取出最大billdate的一条数据 select * from (select table_a.code, table_a.name, table_b.billdate, row_number() over(partition by table_a.pk_house, table_a.pk_customer order by table_b.billdate desc) rn from table_a left join table_b on table_b.pk_table_a table_a.pk_table_a where table_a.code 11111) where rn 1