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, ...
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 & ...
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
...
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 ...
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() ....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
join × 1985mysql × 747
postgresql × 379
sql-server × 377
performance × 204
query × 128
query-performance × 122
oracle × 111
select × 109
subquery × 107
group-by × 96
optimization × 84
index × 69
count × 67
t-sql × 61
update × 61
mariadb × 55
database-design × 49
aggregate × 48
union × 48
view × 41
foreign-key × 32
execution-plan × 31
sum × 30
innodb × 26