sql - Declare variable -
i error message:
msg 164, level 15, state 1, line 18
eachgroup by
expression must contain @ least 1 column not outer reference
from t-sql code:
declare @client_count int select @client_count = count(clt_nbr) client select case when status = 3 'category1' else 'category2' end category, count(*) count, @client_count [total client], count(*) / @client_count percentage client_status status in (3, 8) group status, @client_count
can me fix it?
thank you!
your syntax wrong. need put of values need returned before from
.
declare @client_count int select @client_count = count(clt_nbr) client select case when status = 3 'category1' else 'category2' end category , count(status) statuscount , @client_count [total client] , count(status) / @client_count percentage client_status status in ( 3 ,8 ) group status
Comments
Post a Comment