所以我有一些基本上是
的查询 select *
from tiket
where storno = 'yes'
and time_storno > '2016-07-25 11:48:48.062'
order by time_storno asc limit 100
我是否可以修改此查询以添加另一列,每列中包含此表中的行数?该表的行数可能少于100。
答案 0 :(得分:2)
select *, count(*) over () as row_count
from tiket
where storno = 'yes'
and time_storno > '2016-07-25 11:48:48.062'
order by time_storno asc
这将包含满足条件的行数(因此row_count
与该查询返回的行数相匹配)。
如果您想获得总行数(不包含where
子句),请使用标量子查询
select *, (select count(*) from tiket) as row_count
from tiket
where storno = 'yes'
and time_storno > '2016-07-25 11:48:48.062'
order by time_storno asc