• Shaarli
  • Tag cloud
  • Picture wall
  • Daily
  • RSS
  • Login
4251 shaares
Filters

SQL “Lateral Join” … do you know this SQL join? (EN) – BlogFaq400

QRCode

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 ;
https://blog.faq400.com/en/db2-for-i/sql-lateral-join-db2-for-i-en/
February 9, 2021 at 1:25:09 PM EST *
sql as400
FILLER
Shaarli · The personal, minimalist, super fast, database-free, bookmarking service by the Shaarli community · Documentation
Fold Fold all Expand Expand all Are you sure you want to delete this link? Are you sure you want to delete this tag? The personal, minimalist, super fast, database-free, bookmarking service by the Shaarli community