I have a data set, That was set up using a vary complicated querry. I had quite a bit of help by a gentleman who was vary vary good as sql.
Now I want to add a column that counts the number of identical [ssn] in each [ssn] group. In a sql it would look kind of like this "Select ...,...,..., Count[ssn] as SSNcount from....
How can I add the column without messing with the original querry?
Here is the original working query
SELECT
DISTINCT SSN,
Job_Dispatch_Date,
First_Name,
Last_Name,
CID_Phone,
CID_Name,
Call_Start_Time,
Password_Used,
Call_Type
FROM LoggedCalls
WHERE InStr(Call_Type,'Call') > 0
AND Job_Dispatch_Date IN (
SELECT Job_Dispatch_Date
FROM LoggedCalls AS Tmp
GROUP BY Job_Dispatch_Date, SSN
HAVING Count(*)>1 AND SSN = LoggedCalls.SSN
)
AND (
SELECT COUNT(*)
FROM LoggedCalls AS LoggedCalls1
WHERE LoggedCalls.SSN = LoggedCalls1.SSN
AND LoggedCalls.Job_Dispatch_Date=LoggedCalls1.Job_Dispatch_Date
AND LoggedCalls1.Password_Used IS NOT NULL
) >= 1
;
Now I want to add a column that counts the number of identical [ssn] in each [ssn] group. In a sql it would look kind of like this "Select ...,...,..., Count[ssn] as SSNcount from....
How can I add the column without messing with the original querry?
Here is the original working query
SELECT
DISTINCT SSN,
Job_Dispatch_Date,
First_Name,
Last_Name,
CID_Phone,
CID_Name,
Call_Start_Time,
Password_Used,
Call_Type
FROM LoggedCalls
WHERE InStr(Call_Type,'Call') > 0
AND Job_Dispatch_Date IN (
SELECT Job_Dispatch_Date
FROM LoggedCalls AS Tmp
GROUP BY Job_Dispatch_Date, SSN
HAVING Count(*)>1 AND SSN = LoggedCalls.SSN
)
AND (
SELECT COUNT(*)
FROM LoggedCalls AS LoggedCalls1
WHERE LoggedCalls.SSN = LoggedCalls1.SSN
AND LoggedCalls.Job_Dispatch_Date=LoggedCalls1.Job_Dispatch_Date
AND LoggedCalls1.Password_Used IS NOT NULL
) >= 1
;