How to reference one CTE twice?

后端 未结 5 1439
粉色の甜心
粉色の甜心 2020-12-15 17:44

I have a very fat common table expression which includes row numbers so that I can return a paged result set. I also want to return the total number of records that match th

5条回答
  •  醉梦人生
    2020-12-15 18:26

    You could append a field that has the total rows in it, of course it will be on every row

    select recs.*,totalrows = (select count(0) from recs) 
    from recs
    

提交回复
热议问题