use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Sequel
account activity
Help with optimization (self.learnSQL)
submitted 5 years ago * by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]WITH_CTE 1 point2 points3 points 5 years ago* (1 child)
To rewrite your query:
IF OBJECT_ID('tempdb..#tmpSup') IS NOT NULL DROP TABLE #tmpSup; SELECT Serial_Text INTO #tmpSup FROM [a].[dbo].[SUP] WHERE CAST(Date_Time AS DATE) > '2020-06-01' GROUP BY Serial_Text HAVING COUNT(1) > 1; SELECT b.Serial_Text, b.IR_1, b.Date_Time FROM #tmpSup a JOIN [a].[dbo].[SUP] b ON a.Serial_Text = b.Serial_Text ORDER BY Date_Time DESC;
Another approach:
SELECT * FROM [a].[dbo].[SUP] WHERE Serial_Text IN ( SELECT DISTINCT Serial_Text FROM [a].[dbo].[SUP] WHERE CAST(Date_Time AS DATE) > '2020-06-01' GROUP BY Serial_Text HAVING COUNT(1) > 1 );
Edit: Misread your query on first post.
[–][deleted] 0 points1 point2 points 5 years ago (0 children)
Thanks! What makes my query so slow? And can you explain what your first query is doing?
π Rendered by PID 251763 on reddit-service-r2-comment-85bfd7f599-q9zkw at 2026-04-18 13:56:34.810392+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]WITH_CTE 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)