SQL 쿼리에 대한 도움이 필요합니다. 많은 항목이있는 표가 하나 있는데 마지막 3 열의 값이 동일한 항목을 모두 조회하려고합니다. 다음과 같이SQL "거의"중복 항목 (마지막 3 열에 대해 동일한 값)에 대한 쿼리
내 표는 같습니다
|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
그래서 나는 지난 3 열에 대해 동일한 값을 가진 모든 행을 가져올 지, 그래서 결과는 같아야합니다 :
|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)
누구든지 이것을 관리하는 방법을 알고 있습니까? 지금까지 시도 무엇 했다 :
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;
하지만 작동하지 않았다!
누군가 나를 도울 수 있기를 바랍니다. thx 미리 ...
지난 3 열에 동일한 값이없는 당신의 예제 결과에주는 행. – liquorvicar
이 관련 기사는 당신의 힌트 + 답을 위해서 http://beemerguy.net/blog/post/How-to-remove-duplicate-SQL-table-entries-(by-example).aspx – BeemerGuy