• Skip to main content
  • Skip to primary sidebar

Datannum

Data science for small business applications

  • Home
  • Microsoft Excel (spreadsheet) forum
    • Project: Analyze NYSE Data
  • SQL forum
    • Project: Query a Digital Music Store Database
  • Tableau forum (data visualization)
    • Project: Data Visualization Project using Tableau
  • Linear Algebra forum
    • Curated resource to learn linear algebra
  • Web development
    • WordPress forum
    • Google Support

Counting number of records after applying Cartesian JOIN

Data Science 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

    • How to print winner January 21, 2023
    • find_min function and infinite loop when a candidate not winner in first instance January 17, 2023
    • Bool variable won and print_winner function January 12, 2023
    • True condition with while loop January 6, 2023
    • How to finally display result in tabular form of choices entered by voters December 12, 2022

    Subscribe via Email

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

    This website hosted on WP Engine

    Initiative by Digital Splendid OPC Pvt. Ltd. & Techcosec Limited