|
-
Mar 9th, 2005, 01:52 AM
#1
Thread Starter
Lively Member
Data Manipulation
Hi i want to get records between 2 years month wise, order by month
which should show records like
total : thisdate
----------------
50 : may 01
60 : dec 01
50 : jan 02
etc.
im using this query but, i want if there is no data in any month within defined range it should show "0" in that month field.
at this time it is showing records which has only data in it.
select count(*) total, datename(month,[date]) as thisdate
from prof_midt
where [date] between '1/1/2003' and '2/1/2005'
group by ([date])
order by [date]
Adeel.
Last edited by adeelahmed; Mar 9th, 2005 at 03:43 AM.
Adeel Ahmed
-
Mar 9th, 2005, 11:07 AM
#2
Fanatic Member
Re: Data Manipulation
You need to create a temporary table and populate it (with a cursor) with a record for every month in your date range. Then do a left outer join from it to the results of your query.
p.s. Your question should be in the databases forum really...
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|