CST 363 Introduction to Database
1- SQL has the flexibility to join tables on any column(s) using any predicate (=, >, < ). Most of the time the join will use equality between a primary and foreign key.
One example of SQL-JOIN other than keys are the non-equijoin, cross-join, and self-join. In many cases these types of joins are helpful in tracking objects quantities, benchmarking, threshold control, or obtaining statistical data.
Take a look at this scenario. Imagine a retail store management wants to understand the effectiveness of a marketing campaign that offers discounts during specific months. The SQL join returns any month where the sales profit is larger than regular full price profit (Finance.Profit)
SELECT Month, Discount, Finance.Profit, Sales.SalesProfit
FROM Finance
Left Join Sales
ON SalesProfit > Finance.Profit;
2-
No comments:
Post a Comment