Transaction - ID Customer - Id Channel Product Price Discount: Is The Alias' For and Is Designated Using
Transaction - ID Customer - Id Channel Product Price Discount: Is The Alias' For and Is Designated Using
COUNT(*)
SELECT COUNT(*) OR
9 9
FROM TRANSACTIONS
Table Aliases:
SELECT CHANNEL, PRODUCT, PRICE
FROM TRANSACTIONS
OR
OR
A.KEY
A B A B A B
SQL – JOIN Statements
TRANSACTIONS PRODUCTS
Product Material Medium
Book Stock Paper Visual
Transaction_ID Product
DVD Plastic Audiovisual
Customer_ID Material
Magazine Glossy Paper Visual
Channel Medium
CD Plastic Audio
Product
Newspaper Newsprint Visual
Price
MP3 Digital Audio
Discount
SQL – JOIN Statements
Let’s say I want more information about the products that were
actually purchased:
SELECT a.*, b.*
FROM TRANSACTIONS a
LEFT JOIN PRODUCTS b
ON a.PRODUCT = b.PRODUCT
• In this case, the query would actually return the same result
• However, if a product were missing from the PRODUCT table,
those transactions would be eliminated
• Sometimes this is desirable, sometimes not, depending on the
question you are trying to answer!
SQL – JOIN Statements
Why not a FULL OUTER JOIN?