i am having syntax error with the following sql statement
the thing is i wan to count duplicate in 3 differents columns in a table.
i am using visual studio 2010 and .NET Framework Data Provider for OLE DB
this query will return all entry in one recordset
string testqry =
SELECT NO_IDENT_1 As NO_IDENT_2 FROM P240538 WHERE (P240538.DATE_dt > {2011/04/25})
Union All
SELECT NO_IDENT_2 FROM P240538 WHERE (P240538.DATE_dt > {2011/04/25})
Union All
SELECT NO_IDENT_3 As NO_IDENT_2 FROM P240538 WHERE (P240538.DATE_dt > {2011/04/25});
but the following will signal syntax error
string RqNbIdent10 =
"SELECT COUNT(*) as repeat
from (
SELECT NO_IDENT_1 As NO_IDENT_2 FROM P240538 WHERE (P240538.DATE_dt > {2011/04/25})
Union All
SELECT NO_IDENT_2 FROM P240538 WHERE (P240538.DATE_dt > {2011/04/25})
Union All
SELECT NO_IDENT_3 FROM P240538 WHERE (P240538.DATE_dt > {2011/04/25})
) GROUP BY NO_IDENT_2"
You need to identify the sub-select result set, here I have identified as results.