I am trying to retrieve result from a sql queries which returns duplicated userids from Table1 into Table3.
Below is my sql statement:
INSERT INTO Table3(UserID, Name, Issue)
SELECT t1.UserID, t1.Name, 'Duplicated userid found in Table1'
FROM Table1 t1
GROUP BY t1.UserUD
HAVING COUNT(*) > 1
However, I received the following error after I tried to run it in my datasource:
Column ‘Table1.Name’ is invalid in the select statement list because it is not contained in either an aggregate functions or the GROUP BY
clause
May I know where is my mistake?
Thank you
You were missing the field in the group by