SQL SERVER INNER JOINS AND TOP 100
--We are looking at the inner join query in SQL SERVER MANAGEMENT STUDIO
--Let us start
-- We will begin by joining the Customer table to the Geography table
SELECT TOP 100 *
--WE BEGIN BY SELECTING THE TOP 100 RECORDS
FROM DBO.DimCustomer AS C INNER JOIN DBO.DimGeography AS G
--THEN WE SPECIFY WHAT TABLES WE WOULD LIKE TO INNER JOIN TO FIND EXACT MATCHES
--WE THEN USE THE ALIAS NAME OF C FOR CUSTOMER AND G FOR GEOGRAPHY
ON C.GeographyKey=G.GeographyKey;
--WE FINALLY SPECIFY WHAT KEY FIELDS TO JOIN TOGETHER
--THE KEY FIELDS JOINED ARE THE FOREIGN KEY ON CUSTOMER JOINED TO THE PRIMARY KEY IN GEOGRAPHY NAMED GEOGRAPHYKEY
--THEN RUN THE QUERY BY HIGHLIGHTING THE CODE AND PRESSING F5
No comments:
Post a Comment