簡體   English   中英

我如何計算訂單數量,然后使用 SQL 中的案例語句對它們進行分組

[英]how can i count number of orders and then group them using case statements in SQL

所以我有一個看起來像這樣的表:[table image]

1

我想要的 output 是這樣的:[我想要的 output 圖像]

2

似乎是一個簡單的分組和計數:

select cust_id , count(*) ordrnumber , concat('ordered ' , count(*),' time(s)') as group 
from table
group by cust_id

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM