Daily Shaarli
All links of one day in a single page.
Lateral Join SQL DB2 for i: not everybody knows about it but it’s very powerful in our queries.
We want to get out one row only for each carmaker with the most sold model.
CROSS JOIN LATERAL:
SELECT a.Brand, Country, Modell, Year, Quantity FROM Faq400.AutoBrands A
cross JOIN LATERAL
(SELECT * from faq400.AutoStats stat
WHERE Year=2018 and A.idBrand=stat.IdBrand
order by Quantity desc
FETCH FIRST 1 ROW ONLY
) B ;