all groups > sql server new users > january 2006 >
You're in the

sql server new users

group:

Multiple queries, one report


Multiple queries, one report Steve1445
1/25/2006 2:05:05 PM
sql server new users:
Anyone give me some pointers on pulling several queries into one report? I
need to sum up a numerical field and then show it as one line in a report.
The same table is being queried over and over again, with only a change in
the organziation.propertytype. Thanks

SELECT SUBSCRIPTION.PRICEAMT, ORGANIZATION.ORGNAME,
ORGANIZATION.ISMEMBERFLG, ORGANIZATION.STATUSSTT,
ORGANIZATION.PROPERTYTYPE
FROM SUBSCRIPTION INNER JOIN
ORGANIZATION ON SUBSCRIPTION.CUSTOMERCD =
ORGANIZATION.ORGCD
WHERE (ORGANIZATION.ISMEMBERFLG = 'y') AND (ORGANIZATION.STATUSSTT =
'active') AND (ORGANIZATION.PROPERTYTYPE BETWEEN '54%' AND
'549999')

ORDER BY PRICEAMT
COMPUTE SUM(SUBSCRIPTION.PRICEAMT)
Re: Multiple queries, one report Louis Davidson
1/25/2006 9:58:19 PM
Why not group by the propertyType (and any other columns that are dependent
on propertyType)? Then get rid of COMPUTE and use WITH ROLLUP on the GROUP
BY and it will include the summary values in the output.

I am a bit frightened by
SUBSCRIPTION.CUSTOMERCD = ORGANIZATION.ORGCD

If I saw this design, I would expect that these were quite different
values...


--
----------------------------------------------------------------------------
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)

[quoted text, click to view]

Re: Multiple queries, one report Steve1445
1/26/2006 12:02:03 PM
Thank you for your input. I ended up querying the data from within Excel, it
worked quite well and the user is comfortable with the app.

[quoted text, click to view]
AddThis Social Bookmark Button