SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 I Need count for this statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

MageshkumarM
Yak Posting Veteran

India
61 Posts

Posted - 02/03/2011 :  02:22:19  Show Profile  Reply with Quote
Hi,

I need one small doubt to count datas in a statement.

statement:-

[ select date from table1 group by datepart(year, year(date)); ]

this statement will returns 10 rows.

I need to count this 10 rows in single value..

for ex:
*******
count( select date from table1 group by datepart(year, year(date));)
-
so, i want count is [ count = 10 ].

can anyone help me out this..





MAG,
Start with the new Idea..
http://mageshkumarm.blogspot.com/

sohail.mahmood69
Starting Member

Qatar
7 Posts

Posted - 02/03/2011 :  02:46:07  Show Profile  Reply with Quote
Its like this

select COUNT(date) from table1 group by datepart(year, year(date));

Sohail Malik
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22761 Posts

Posted - 02/03/2011 :  03:24:35  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
select COUNT(date) as c from table1 group by datepart(year, date);


or

select sum(c) as counting from
(
select COUNT(date) as c from table1 group by datepart(year, date)
) as t

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

MageshkumarM
Yak Posting Veteran

India
61 Posts

Posted - 02/03/2011 :  03:27:45  Show Profile  Reply with Quote
ok thanks guys i got it..!

MAG,
Start with the new Idea..
http://mageshkumarm.blogspot.com/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  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.06 seconds. Powered By: Snitz Forums 2000