Code Like A Girl
Read post

SQL Cross Apply — When SQL Thinks Like a Recommendation Engine

SQL's CROSS APPLY operator is explained through the analogy of an e-commerce recommendation engine. Unlike a standard JOIN, CROSS APPLY runs a subquery for each individual row — in this case, fetching the top 3 personalized product recommendations per customer ordered by score. A side-by-side comparison with a CTE + ROW_NUMBER() JOIN approach shows that CROSS APPLY produces cleaner, more readable code for per-row logic. Use cases include top-N results per group, dynamic per-row filtering, and calling table-valued functions.

    #backend#sql#recommendation-systems
Jul 09•5m read time•From code.likeagirl.io
Post cover image
Table of contents
What is actually happening?What do this and CROSS APPLY have in common?How does CROSS-APPLY think?Get Luchiana Dumitrescu’s stories in your inbox
781 Impressions
Code Like A Girl's image
Code Like A Girl

Colkgirl shines a spotlight on women in tech, diversity, and inclusion initiatives, providing a plat...

281 Followers

•

3.9K Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard