• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Datannum

"Empowering Insights, Unleashing Possibilities - Datannum.com"

  • Home
  • Microsoft Excel (spreadsheet) forum
    • Project: Analyze NYSE Data
  • SQL forum
    • Project: Query a Digital Music Store Database
  • Data Visualization
    • Project: Data Visualization Project using Tableau
    • IBM – Cognos Analytics/Planning Analytics/Cognos Controller with Watson
  • Linear Algebra forum
    • Curated resource to learn linear algebra
  • Hire Us/Support

Counting number of records after applying Cartesian JOIN

Data Science/Business Analytics for Small Business Applications › Forums › SQL › Counting number of records after applying Cartesian JOIN

Tagged: Cartesian join SQL

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • April 22, 2022 at 10:12 am #141
    Admin
    Keymaster

      Here is the problem:

      All of the questions in this quiz pull from the open source Chinook Database. Please refer to the ER Diagram below and familiarize yourself with the table and column names to write accurate queries and get the appropriate answers.

      SQL Coursera

      How many records are created when you apply a Cartesian join to the invoice and invoice items table?

      Here is my tentative solution:

      SELECT *
      FROM invoices
      JOIN invoice_items
      ON invoices.invoiceid = invoice_items.invoiceid

       

      The solution that I am getting of 2240 records incorrect (Output limit exceeded, 25 of 2240 total rows shown).


      Seeking help where I am going wrong.


      Reply


      Cartesian join == CROSS JOIN

      https://www.sqlitetutorial.net/sqlite-cross-join/

      The question is perhaps what happens when you apply a Cartesian JOIN to the two tables (no filtering with a WHERE clause). Your original query filters the results, so you’re not getting a proper count of rows.

      Combine CROSS JOIN with COUNT.

      SELECT COUNT(*)
      FROM invoices
      CROSS JOIN invoice_items

      In SQLite JOIN without an ON clause is effectively the same as a CROSS JOIN.

    • Author
      Posts
    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Log In

    Primary Sidebar

    profile for Techcosec Limited on Stack Exchange, a network of free, community-driven Q&A sites

    RSS CS50’s Introduction to Computer Science by Harvard University on Edx

    Subscribe via Email

    Enter your email address to subscribe and receive notifications of new posts by email.

    This website hosted on WP Engine

    Footer

    Hosted on WP Engine

    Powered by
    • Terms
    • Privacy
    • Disclaimer