标签:实战 order select 需求 sql _id count 成交 text
select * from table;
id | order_id |
---|---|
c1 | 1 |
c1 | 2 |
c1 | 3 |
c2 | 4 |
c2 | 5 |
c3 | 6 |
... | ... |
c100 | 10000 |
为了满足需求,SQL可以这样子写:
select
id,
count(order_id) as sales
from
t
where id <> "xxx"
group by
id
having
count(order_id) > 10
order by
count(order_id) desc
limit 3;
代码中涉及SQL关键词:select
、from
、where
、group by
、having
、order by
、limit
执行优先顺序:from
- where
- group by
- having
- select
- order by
- limit
标签:实战 order select 需求 sql _id count 成交 text
原文地址:https://www.cnblogs.com/hider/p/11612907.html