SQL > SQL????? > ??

?? ??? ??(join)? ??? ?????. ??? ?? ????? ?? ??? ??????? ?? ???? ???. ?? ???? ??? ?? ??? ??? ??? ?????,

Store_Information ??
Store_NameSalesTxn_Date
Los Angeles150005-Jan-1999
San Diego25007-Jan-1999
Los Angeles30008-Jan-1999
Boston70008-Jan-1999

Geography ??
Region_NameStore_Name
EastBoston
EastNew York
WestLos Angeles
WestSan Diego

??? ?? ?? (Region_Name) ? ??? (Sales) ? ??? ???. Geography ? ??? ???? ?? ??? ?? ??? ????? ???? Store_Information ? ???? ?? ??? ???? ?????. ?? ??? ???? ??? ??? ? ???? ???? ????? ???. ? ? ??? ???? ??? ?? ??, Store_Name ? ??? ?????? ?? ????. ??SQL ?? ???? ???? ??? ?????:

SELECT A1.Region_Name REGION, SUM(A2.Sales) SALES
FROM Geography A1, Store_Information A2
WHERE A1.Store_Name = A2.Store_Name
GROUP BY A1.Region_Name;

??:

REGION SALES
East 700
West 2050

???? ???SQL?? ??? ??? ???? ?????. ??? ??? Geography ???? Region_Name ????(??? REGION); ??? ??? Store_Information ???? sales ?? (???SALES)???. ??? ??? ?? ??? ?????? ?? ?? ???. Geography ??? ??? A1, Store_Information ??? ??? A2. ?? ??? ???? ??? ?? ??? ?? ????,

SELECT Geography.Region_Name REGION, SUM(Store_Information.Sales) SALES

??? ?? ?? ??????. ??? ??? ?? ??? ??? ?? ????. ?? ???? ???? ??SQL ??? ?? ?? ???? ????.?? SQL ??? ???? ??? ??? ???? ???.

???? ??? ?? WHERE ?? ???. ??? ??? ????? ???? ????. ??? ??? Geography ???? Store_Name ??? ??? Store_Information ??? Store_Name ??? ??? ????? ????? ???. ? WHERE ?,? ?????? ?? ???? ? ???? ??? ?? ??? ???? ?????. ?? WHERE ?? ??? ???? ??? ??? ?????? (Cartesian join)? ?? ???? ????. ???? ??? ?? ??? ?? ?? ??? ? ???? ?? ??? ??? ?????. ? ??? ???? ??? ?? ??? 4 x 4 = 16 ?? ??? ?? ???.

SQL ???? >>
?


Copyright © 2021   1keydata.com   All Rights Reserved