[AccessD] SQL Query Grouping

Millard, Paul --- Sr. Developer Analyst ---WGO Paul.Millard at freight.fedex.com
Tue Jan 13 15:38:41 CST 2004


Folks,

I need help with an SQL querying using SQL Server.  The query below works fine...it's a simple grouping query that displays count of records, sum of revenue etc.  However, what I'm trying to accomplish is to force each grouping such as 1, 2, and 3 (see below) even when records do not exist.  Normally, a group query only shows the groupings where records exist.  How can I accomplish this?  My initial thoughts are to create the groupings in separate table and try to link them.  Not sure how that can be done in SQL.

Thanks in advance.
Paul Millard
San Jose, CA
	


sSQL = "SELECT " & _
"Case " & _
"When StdDays = 1 Then 1 " & _
"When StdDays = 2 Then 2 " & _
"When StdDays >= 3 Then 3 " & _
"Else 0 End As StdDays, " & _
"Count(Pro) As Bills, " & _
"Sum(Rev) As Rev, " & _
"Sum(Wt) As Wt " & _
"FROM tblOpus " & _
"WHERE Rpt = 'R' " & _
"GROUP BY " & _
"Case " & _
"When StdDays = 1 Then 1 " & _
"When StdDays = 2 Then 2 " & _
"When StdDays >= 3 Then 3 " & _
"Else 0 End " & _
"ORDER BY StdDays"


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************



More information about the AccessD mailing list