I need help with an SQL-Query. I have one table with many entries and I want to query all the entries which have the same values for the last 3 columns.
My table looks as follows:
|Refrigator|98C08A|2011-08-06 00:00:30|126|126
|Refrigator|B7BE29|2011-08-06 00:00:30|73|70
|Refrigator|599393|2011-08-06 00:00:30|126|126
|Refrigator|B7BE29|2011-08-06 00:00:29|73|70
|Refrigator|599393|2011-08-06 00:00:29|126|126
|Refrigator|599393|2011-08-06 00:00:29|126|126
|Refrigator|98C08A|2011-08-06 00:00:29|126|126
|Refrigator|98C08A|2011-08-06 00:00:29|126|126
|Refrigator|599393|2011-08-06 00:00:28|126|126
So I want to get all rows, which have the exact same values for the last 3 columns, so the result should look like:
|Refrigator|98C08A|2011-08-06 00:00:30|126|126
|Refrigator|599393|2011-08-06 00:00:30|126|126
|Refrigator|599393|2011-08-06 00:00:29|126|126
|Refrigator|599393|2011-08-06 00:00:29|126|126 (if possible without this duplicate)
|Refrigator|98C08A|2011-08-06 00:00:29|126|126
|Refrigator|98C08A|2011-08-06 00:00:29|126|126 (if possible without this duplicate)
Does anyone have an idea how to manage this? What I tried so far was:
SELECT *
FROM smtab
WHERE Datetime IN (
SELECT Datetime
FROM smtab
GROUP BY Datetime
HAVING count(Datetime) >1)
AND Power1 IN (
SELECT Power1
FROM smtab
GROUP BY Power1
HAVING count(Power1) >1)
AND Power8 IN (
SELECT Power8
FROM smtab
GROUP BY Power8
HAVING count(Power8) >1)
ORDER BY Datetime DESC;
but I didn't work!!!
Hope someone can help me! thx in advance...