`GROUP BY`表达

时间:2016-04-19 20:08:54

标签: sql tsql

我收到错误消息:

  

Msg 164,Level 15,State 1,Line 18

每个GROUP BY表达式必须包含至少一个不是以下TSQL的外部引用的列:

DECLARE @CLIENT_COUNT INT

SELECT @CLIENT_COUNT=COUNT(CLT_NBR) FROM CLIENT

SELECT 
CASE WHEN STATUS=3 THEN 'CATEGORY1' else 'CATEGORY2' end as Category

,COUNT(*) AS COUNT 

,@CLIENT_COUNT as [Total CLIENT]

,COUNT(*) / @CLIENT_COUNT as PERCENTAGE

FROM CLIENT_STATUS

WHERE STATUS IN (3,8)

GROUP BY STATUS,@CLIENT_COUNT 

你能帮我解决一下吗?

谢谢!

0 个答案:

没有答案