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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Tally Groups

Author  Topic 

molebrain
Starting Member

18 Posts

Posted - 2005-08-01 : 15:53:10
I have a simple SQL question for ya.

I have this table:


tblStudentForm
ID:int,Name:varchar,Locationid:int,Date: datetime

I want it to ouput the number of inquiries for each location between a certain datelike this:

Locationid Number of Inquiries

0 300
1 123
2 43
3 232
7 ….
9 ….


Im guessing this uses the group by and stuff… any ideas? I cant seem to get it to work.

This is what I have tried:

select StudentlocationId, count(*)as 'Total Inquiries' from tblStudentForm where (StudentFormTimeStamp > 6 / 31 / 2005)
group by
StudentLocationID

which ends up looking like this:

StudentlocationId Total Inquiries
----------------- ---------------
0 524
1 23734
2 17086
3 11738
4 12372
5 17593
6 10096

They look like total for the year numbers, not for the month.

Any help is appreciated.

Thanks!



tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-08-01 : 15:56:33
Please post what you have tried as this is a pretty basic question. Instead of us answering the question which it sounds like is a homework question, you'd be better off learning the simple stuff. We'll help you if we see you have the wrong answer.

Other SQLTeamers, please do not answer this question until the poster has at least showed us he/she has tried.

Tara
Go to Top of Page

molebrain
Starting Member

18 Posts

Posted - 2005-08-01 : 16:18:27
quote:
Originally posted by tduggan

Please post what you have tried as this is a pretty basic question. Instead of us answering the question which it sounds like is a homework question, you'd be better off learning the simple stuff. We'll help you if we see you have the wrong answer.

Other SQLTeamers, please do not answer this question until the poster has at least showed us he/she has tried.

Tara



I'm an idiot. got it working. Sorry for the post.

select studentlocationid, count(*) from tblStudentForm
where StudentFormTimeStamp between '7/1/2005' and '7/31/2005'
group by studentlocationid
order by studentlocationid,count(*)
Go to Top of Page
   

- Advertisement -