can someone please help me.i wanted to count the rows of a table for today,30 days back,90 days back and 180 days back.can someone please help me to write a code for this in sql.thanks
count the rows
Collapse
X
-
will this work?
-- CKCode:select 30days = sum(case when abs(datediff(dd,getdate(),yourdatefield)) = 30 then 1 else 0 end), 60days = sum(case when abs(datediff(dd,getdate(),yourdatefield)) = 60 then 1 else 0 end) 90days = sum(case when abs(datediff(dd,getdate(),yourdatefield)) = 90 then 1 else 0 end) from yourtable
-
i have to i have data in my table.i need to count the open issues for today ,30 days back,90 days back,180 days back.
i wrote a stored procedure
select projectname,cou nt('x') as "today's count",(select count('x') from table1 where(datediff( day,date_submit ted.getdate())> =30) group by projectname)as "30 days back count",(select. ......).
when i write stored procedure like this i get a error as subquery returns more than 1 row.
so i tried to write the subquery in the from clause.like
select projectname,cou nt('x) as "todays count"
from(select count('x') where datediff(day,da te_submitted,ge tdate())>=30) as "30 days bck count
from table1
groupby projectname)
here too i get the error as incorrect keyword near from.i don't know how to fix it.can you please help me.thanks
--Comment
Comment