Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
saulfeliz
Starting Member
14 Posts |
Posted - 2012-01-26 : 10:20:44
|
| I've been trying to rename a query with the AS clause. But it seems when I combine it with an aggregation function like COUNT, it doesn't work. Anybody know why?Here's the query:SELECT DISTINCT Count (*) UID_XID AS 'Interactors' FROM [TABLE NAME] WHERE VARIABLE_1 IN ('ASDQ6KJ8un4Q') AND VARIABLE_2 IN (11) AND UID_XID IN ( SELECT DISTINCT UID_XID FROM [TABLE NAME] WHERE VARIABLE_1 IN ('ASDQ6KJ8un4Q') AND VARIABLE_2 IN (11) AND VARIABLE_3 IN (p))GOResult:Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'AS'.If I take away the Count (*) it works. Why is that? I tried moving the AS around, (like putting it in the subquery) but nothing works. Help? Thanks!Saul |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-01-26 : 10:34:12
|
SELECT DISTINCT Count (*) UID_XID AS 'Interactors' What do mean?SELECT Count(*) AS 'Interactors' orSELECT Count(UID_XID) AS 'Interactors' orSELECT Count(DISTINCT UID_XID) AS 'Interactors' No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
saulfeliz
Starting Member
14 Posts |
Posted - 2012-01-26 : 10:40:27
|
| I see it was the second option. That was Easy.Thank you Fred! |
 |
|
|
|
|
|