I have an SQL query where I want to choose in a table individual names from one column that occur more than once in another column. My query so far looks like this:
PatientCode, BirthDate, COUNT() AS regionCount
COUNT() > 1
SUM (regionCount) AS Total
I assume (at least) there is an error in line 10:
Msg 207, Level 16, State 1, Line 10
Invalid column name 'regionCount'.
In line 1 I try to create a temporary column name "regionCount" since if I don't, all the counted values will end up in a column "No column name" and such a name of a column seems not to be accepted.
What I really would like to do is to add all values from the "No column name" column:-)