May 21, 2007 at 12:00 pm
I have an idea, post sample data, sample results, and what YOU have done so far and what results YOU have gotten so far. Then we can help you figure out what is wrong instead of doing your work for you.
![]()
May 21, 2007 at 5:08 pm
Read up on WITH ROLLUP in BOL....
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgMay 21, 2007 at 11:13 pm
Go for broke... read up on WITH CUBE in BOL... that's where they teach you about the GROUPING function that works both with ROLLUP and CUBE.
--Jeff Moden
Change is inevitable... Change for the better is not.
May 23, 2007 at 8:04 am
Here is an extremely simple example of what you might try.
I am using a pass-thru query in Access to display the number of members updated within the past five days AND they also wanted to see the grand total, all in the same query...
CREATE PROC [dbo].[procUpdatesPending]
AS
DECLARE
@today smalldatetime
SELECT
@today = dbo.fnNoTime(GETDATE())
SELECT
dbo.fnNoTime(UpdatedDateTime) AS LastUpdated,
COUNT(*) AS Members,
'A' AS TheSort
INTO
#temp
FROM
PERSON
WHERE
dbo.fnNoTime(UpdatedDateTime) BETWEEN DATEADD(d,-5,@today) AND @today
GROUP BY
dbo.fnNoTime(UpdatedDateTime)
UNION
SELECT
NULL,
COUNT(*) AS Members,
'B' AS TheSort
FROM
PERSON
WHERE
dbo.fnNoTime(UpdatedDateTime) BETWEEN DATEADD(d,-5,@today) AND @today
SELECT
LastUpdated,
Members
FROM
#temp
ORDER BY
TheSort
DROP TABLE #temp
BTW - the dbo.fnNoTime() is a UDF that strips out the time portion.
May 23, 2007 at 8:16 am
You might want to post your code for the UDF dbo.fnNoTime() as I doubt Best will figure out how to write it.
![]()
May 23, 2007 at 8:24 am
I posted in another forum just today, take a look at
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=9&messageid=367982
Viewing 6 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply