|
|
Question : Query HELP: "...introduced with EXISTS." Error
|
|
I have the following query below:
SELECT DISTINCT 'true' ReturnMsg, ipStatus, ipAddress, ipAgent, ipMessage, createDt, (SELECT DISTINCT ipAddress, COUNT(ipAddress) AS ipCount FROM formIPContact WHERE (ipStatus = 0) GROUP BY ipAddress) AS ipCount FROM formIPContact WHERE ipStatus = 0 AND (createDt Between DateAdd(day, -1, getDate()) AND getDate())
returns this error:
"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."
I'm trying to COUNT existing individual records while returning DISTINCT examples of each. Can I do this with one query? Thanks in advance!
|
Answer : Query HELP: "...introduced with EXISTS." Error
|
|
SELECT ReturnMsg, ipStatus, ipAddress, ipAgent, ipMessage, createDt, count(*) as ipCount FROM formIPContact WHERE ipStatus = 0 AND (createDt Between DateAdd(day, -1, getDate()) AND getDate()) GROUP BY ReturnMsg, ipStatus, ipAddress, ipAgent, ipMessage, createDt
|
|
|
|
|