[英]SQL order and limit on a result of a query
我有一個查詢,該查詢按列a排序並限制為100。然后我要對該結果運行查詢,該結果按b列排序並限制為50。
我怎樣才能做到這一點?
在派生表中order by
/ limit
進行一次order by
。 然后對派生表的結果order by
/ limit
進行第二次order by
:
select * from
(
select * from tablename
order by a
limit 100
) dt
order by b
limit 50
您應該使用select from select
語句:
select a, b
from (
select a, b
from table1
order by a
limit 100
)
order by b
limit 50
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.