Assume the following schema:
Calculate the number of songs that either did not make the charts or entered the charts and had a max rank greater than 90. The result should look like the following:Number of songs |
---|
4845 |
SELECT count(*) as 'Number of songs'
FROM songs t1 LEFT JOIN charts t2
ON t1.trackid = t2.trackid
where maxRank is Null or maxRank > 90;
Number of songs |
---|
4845 |
Alternatively, we can use a subquery:
SELECT count(*) as 'Number of songs'
FROM songs t1
WHERE t1.trackid NOT IN
(SELECT DISTINCT trackid FROM charts WHERE maxRank <= 90)
Number of songs |
---|
4845 |