Hot answers tagged

3 votes

Duplication records with INNER JOIN

If you only need to see rows from MessagesPerf and not MessagesPerfHistory, using an EXISTS subquery will avoid row duplication. Of course, you may see incorrect results with the NOLOCK hint in place, ...
Erik Darling's user avatar
  • 38.8k
2 votes
Accepted

Does SQL implementations (or at least SQL Azure) skip obvious duplicate data with joins when returning data?

It will repeat the content. SQLServer does not try to second guess why you wanted all this data, nor does it try to interpolate to reduce the overall volume sent. If you join tables together & ...
simon coleman's user avatar
1 vote

Duplication records with INNER JOIN

WITH cte1 AS ( SELECT RowId, DateEntered, COUNT(*) cnt FROM MessagesPerf WHERE DateEntered >= '2021-09-01 00:00:00' AND DateEntered < '2021-10-01 00:00:00' GROUP BY 1, 2 ...
Akina's user avatar
  • 19.4k
1 vote

How to apply JOIN only if there are rows available

This is one simple solution. Schema (PostgreSQL v15) CREATE TABLE "Activity" ( "id" INTEGER PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY, "designation" TEXT ...
Caleb Carl's user avatar
1 vote

SQL query to aggregate data from three tables

I know this is an old question but in MySQL version 8 and above we have window functions. I'm quite new to them so I thought I'd practice converting the MAX ... GROUP BY approach into a ROW_NUMBER() ....
Neek's user avatar
  • 123

Only top scored, non community-wiki answers of a minimum length are eligible