I have a select like this:
SELECT
[Status] AS Requested
,[Status] AS [Sent]
,[Status] AS Finished
FROM Store.[Order]
Status
is an int value and I want Count all Status
How can I achieve it? Regards
Use case
expression to count status based on value ( 1,2,3 )
SELECT
SUM(CASE WHEN [Status] = 1 THEN 1 ELSE 0 END) AS Requested,
SUM(CASE WHEN [Status] = 2 THEN 1 ELSE 0 END) AS Sent,
SUM(CASE WHEN [Status] = 3 THEN 1 ELSE 0 END) AS Finished
FROM Store.[Order]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.