The code listed below is being used from inside Crystal Reports to build a
cross tab report showing the total number of clients by level (1,2,3,E, or
P) and Type (I or P). What I would like to do is add some compute statements
(or something) to the end of this query that would show this total rollup
without having to use Crystal.
So for example, the query would show first the site name (i.e. CENTRAL), the
WORKERID assigned to each site (as many as 6 in some cases) then the total,
by workerId of how many I clients (Infants) and how many P clients
(Prenatal) by Assigned to each level (1,2,3,E,P).
This works fine inside Crystal, but in order to place it on the database
system I have to use a SQL code for the Site Managers to run. I have tried a
few COMPUTE statements but cannot get them to work as I need them to.
Any ideas or suggestions?
SELECT Account_Sites.Name, Account_Membership.WorkerID, Clients.SSNum,
Clients.First_Name + ' ' + Clients.Last_Name AS CLIENT,
Clients.clientType, Clients.clientLevel
FROM Account_Membership INNER JOIN
Account_Sites ON Account_Membership.Site_ID =
Account_Sites.ID INNER JOIN
Clients ON Account_Membership.ID =
Clients.Membership_ID

Signature
JOHN C. HARRIS, MPA, MBA
JCZ CONSULTING OF TAMPA BAY
813-361-8826
JCZ@TAMPABAY.RR.COM
John Bell - 31 Oct 2007 19:39 GMT
Hi John
There are CUBE and ROLLUP commands in SQL Server see
http://msdn2.microsoft.com/en-us/library/Aa213210(SQL.80).aspx You may need
to use a derived table with a where clause to eliminate the rows you don't
want, alternatively you can UNION multiple statements and return an extra
value that will enable you to differentiate detail from totals for example
http://tinyurl.com/3cc293
John
> The code listed below is being used from inside Crystal Reports to build a
> cross tab report showing the total number of clients by level (1,2,3,E, or
[quoted text clipped - 21 lines]
> Clients ON Account_Membership.ID =
> Clients.Membership_ID