This is a very good example of where the Cartesian (Cross) Join may be very helpful. Though proper understanding and enough experimentation should be done to try it out.
Jeff @ SQLTeam.com
It explains an example where a Join may be required to return some value ['0'] in this case when there are no matching records found. for e.g. return 0 for sales of all combination of products and stores which dont have a value i.e. null.
SELECT S.Store, P.Product, ISNULL(C.TotalSales,0) as TotalSales
FROM Stores S
CROSS JOIN Products P
LEFT OUTER JOIN
(SELECT Store, Product, SUM(Sales) as TotalSales
FROM Sales
GROUP BY Store, Product) C
ON
S.Store = C.Store AND
P.Product = C.Product
Also Refer:
Join Clause in SQl
Showing posts with label Very Good. Show all posts
Showing posts with label Very Good. Show all posts
Wednesday, June 18, 2008
Tuesday, June 17, 2008
The Golden Rule of Data Manipulation
This is a very good post about data design.
SQLTeam Golden Rule Of Data manipulation
It is suggested that Concatenating is easier than parsing scripts. Thus wherever possible one must segregate the data. e.g Full name phone numbers etc.
SQLTeam Golden Rule Of Data manipulation
It is suggested that Concatenating is easier than parsing scripts. Thus wherever possible one must segregate the data. e.g Full name phone numbers etc.
Tuesday, November 13, 2007
Important Links Related to SQL Server And SQL Programming
1) Microsoft SQL SERVER Programming FAQ :
This Link has many questions and there solutions on MS SQL SERVER..
2) akadia.com
This is an excellent source for guidelines on SQL Server as well as ORACLE and few MS tech like .NET etc.
3) Pinal Dave's Blog
This is an excellent blog, where one can find articles on SQL, and also several question and answers. Do go throught it once.
This Link has many questions and there solutions on MS SQL SERVER..
2) akadia.com
This is an excellent source for guidelines on SQL Server as well as ORACLE and few MS tech like .NET etc.
3) Pinal Dave's Blog
This is an excellent blog, where one can find articles on SQL, and also several question and answers. Do go throught it once.
Subscribe to:
Posts (Atom)
