Reputation: 1700
I need to group by multiple columns and insert the results into a table but one of the columns I need to group by isn't to be inserted, such as the following...
INSERT INTO tbl (fld1, fld2, fld3, fld4)
SELECT DISTINCT fld1, fld2, fld3, fld4, fld5
It won't let me insert the records because of the extra column that I need grouped. Is there a potential workaround for this?
Upvotes: 0
Views: 116
Reputation: 10908
INSERT INTO tbl (fld1, fld2, fld3, fld4)
SELECT fld1, fld2, fld3, fld4
GROUP BY fld1, fld2, fld3, fld4, fld5
Upvotes: 3