美文网首页
PgSql查询样例

PgSql查询样例

作者: codeduck1 | 来源:发表于2021-08-23 10:44 被阅读0次
-- 查询条数
(select * from snucs.biz_collect_record where trade_source = '003' and prod_code ='RXF' and collection_time > '2021-01-01 00:00:00' and collection_time < '2021-07-31 23:59:59'
and id < 1110636 order by id desc limit 2)
union all
(select * from snucs.biz_collect_record where trade_source = '003' and prod_code ='XJZCB' and collection_time < '2021-07-31 23:59:59'
and id < 1110636 order by id desc limit 2)
order by id desc limit 4

-- 查询最大id
(select max(id) id from snucs.biz_collect_record where trade_source = '003' and prod_code ='RXF' and collection_time > '2021-01-01 00:00:00' and collection_time < '2021-07-31 23:59:59')
union all
(select max(id) id from snucs.biz_collect_record where trade_source = '003' and prod_code ='XJZCB' and collection_time < '2021-07-31 23:59:59')
order by id desc limit 1;

相关文章

网友评论

      本文标题:PgSql查询样例

      本文链接:https://www.haomeiwen.com/subject/dmlgbltx.html