SQL SUM A SUM
For some reason, this was hard for me to find when I was searching, so I figured I would post here in hopes that someone
that needs it as bad as I did, comes accross it.
My primary use to a sql statement for a sum a sum is when using a count and group by within a select statement.
For instance:
-
SELECT COUNT(myvarchar_column) mycount
-
FROM tblMyTable
-
GROUP BY myvarchar_column
This returns the count of each unique string in my myvarchar_column.
but what if you want the count to be greater than 5. Its this simple:
-
FROM
-
(
-
SELECT COUNT(myvarchar_column) mycount
-
FROM tblMyTable
-
GROUP BY myvarchar_column
-
) z
-
WHERE mycount > 5