My fields are
ID | Name | StartTime | EndTime | Date | Description
I am looking for a way to select all rows with the same entries in all fields except for the ID.
I am not that familiar with SQL so I tried this approach but there is only one field relevant not (as in my case) five.
My first idea was to try something like:
SELECT *
FROM Table
order by Name, Date, StartTime, EndTime, Description
if I would look through all entries I would at least find the duplicates but that is definitely not the best way to solve the problem.
Jens :
This should do what you need:\n\nselect Name, Date, StartTime, EndTime, Description\nfrom table\ngroup by Name, Date, StartTime, EndTime, Description\nhaving count(*) > 1\n",
2014-11-11T07:40:24
Radu Gheorghiu :
This query should work for you:\n\nSELECT ID, Name, StartTime, EndTime, Date, Description\nFROM (\n SELECT \n ROW_NUMBER() OVER (PARTITION BY ID ORDER BY ID, Name, Date, StartTime, EndTime, Description) AS 'IndexNr'\n , ID\n , Name\n , StartTime\n , EndTime\n , Date\n , Description\n FROM Table) AS ResultSet\nWHERE ResultSet.IndexNr > 1\n",
2014-11-11T07:36:37
user1089766 :
Try below query.\n\nSELECT Name, Date, StartTime, EndTime, Description\nFROM Table\nGROUP BY Name, Date, StartTime, EndTime, Description\nHAVING (COUNT(*) > 1)\n",
2014-11-11T07:40:51