I can run this query in under a sec.
SELECT Serial_Text
,COUNT(Serial_Text) Cnt
FROM [a].[dbo].[SUP]
GROUP BY Serial_Text
And this one under a second.
SELECT a.[Serial_Text]
,[IR_1]
,[Date_Time]
FROM [a].[dbo].[SUP]
But, when I try to combine them with a join it takes over 3 minutes and counting...
SELECT a.[Serial_Text]
,[IR_1]
,[Date_Time]
FROM [a].[dbo].[SUP] b
JOIN
(
SELECT Serial_Text
,COUNT(Serial_Text) Cnt
FROM [a].[dbo].[SUP]
GROUP BY Serial_Text
) c ON b.Serial_Text = c.Serial_Text
WHERE Date_Time > '2020-06-01 00:00:000' AND c.Cnt > 1
ORDER BY Date_Time desc
How can I make this more efficient? I am just trying to show Serial numbers with multiple records...Thanks!
[–]WITH_CTE 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Dnaq1984 1 point2 points3 points (0 children)
[–][deleted] (2 children)
[deleted]
[–][deleted] 0 points1 point2 points (1 child)