In ms sql, I try to count occurence of a computed column .
With a normal classic, no worries:
SELECT ID, COUNT(*)
FROM User
GROUP BY ID
But with calculated column it display an Error
SELECT CONVERT(INT, (ID * PI())) AS TOTO, COUNT(*)
FROM User
GROUP BY TOTO
Do you know if there is a way to do it?
Use this...you want to group by the same computed expression to get the count grouped by that expression
SELECT CONVERT(INT, (ID * PI())) AS TOTO, COUNT(*)
FROM User
GROUP BY CONVERT(INT, (ID * PI()))
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.