Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Group by formats
 Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

Flowing Fount of Yak Knowledge

2242 Posts

Posted - 04/04/2013 :  09:40:53  Show Profile  Reply with Quote
Is this?

SELECT Format, SUM(QtyFree + QtyPaid) AS total
FROM ( Your Query) t

Edited by - bandi on 04/04/2013 09:41:42
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 04/04/2013 :  14:23:15  Show Profile  Reply with Quote
Originally posted by magmo

Hi again

I thought it would be nice to have an additional approach to this query. If I instead of showing QtyPaid and QtyFree as seperate values and instead have them as one value (QtyPaid + QtyFree as SumTotal) how would that be, I tried just to sum them both but then I got a "Cannot perform an aggregate function on an expression containing an aggregate or a subquery." error...

for that this is enough right?

SELECT Format, DATEADD(dd,DATEDIFF(dd,0,DateAdded),0),
	ISNULL(COUNT(NumberOfCards), 0)AS total
FROM tbl_test
WHERE IsFetched = 1 AND Duplicate = 0
AND DateAdded >='2013-03-01' AND DateAdded <'2013-03-04'
GROUP BY Format, DATEADD(dd,DATEDIFF(dd,0,DateAdded),0)

SQL Server MVP
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000