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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 I Need count for this statement

Author  Topic 

MageshkumarM
Yak Posting Veteran

61 Posts

Posted - 2011-02-03 : 02:22:19
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

7 Posts

Posted - 2011-02-03 : 02:46:07
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

22864 Posts

Posted - 2011-02-03 : 03:24:35
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

61 Posts

Posted - 2011-02-03 : 03:27:45
ok thanks guys i got it..!

MAG,
Start with the new Idea..
http://mageshkumarm.blogspot.com/
Go to Top of Page
   

- Advertisement -