Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

How to obtain Sum of count Expand / Collapse
Author
Message
Posted Thursday, January 17, 2013 1:32 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Saturday, May 31, 2014 9:19 PM
Points: 1,128, Visits: 1,162
Steve Jones - SSC Editor (1/16/2013)
This kind of works, but I'm wondering if you've calculated something in this view already.

SELECT cid, COUNT(DISTINCT ccid)
FROM dbo.MyTable
GROUP BY cid



I think this should be fine ..If not please post the ddl's .I am unable to understand the problem..
this is how I tried , le me know it works for you..
CREATE TABLE #test
(
CID INT,
CCID CHAR(10),
CCOUNT INT
)

INSERT INTO #test
VALUES (2,'a',1),
(2,'b',1)
-- Edited this part
SELECT *,

(SELECT SUM(ccount) FROM(SELECT CCOUNT
FROM #test GROUP BY CID,CCOUNT)abc)CountTotal
FROM #test



~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one
Post #1408211
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse