Selecting values from table based on the date

Posted by Bulksms under ASP.NET on 10/20/2011 | Points: 10 | Views : 636 | Status : [Member] | Replies : 1
Hi All,

My table contains UserName, Date, Count.

UserName Date Count

Test 01-08-2011 1
Test 01-08-2011 2
Test 02-08-2011 1
Test 03-08-2011 5

I need to select the values based on the date with group by UserName and date.
Eg:

UserName 1 2 3 .....31

Test 3 1 5 ......

Here 1,2,3 .... indicates date.
2 1 1 ...... indicates count

Can anyone tell me the query for this.

Thanks in advance.
Salini,Kap Computer Solutions




Responses

Posted by: Hmanjarawala on: 10/20/2011 [Member] Bronze | Points: 25

Up
0
Down
select Convert(varchar(15), TDate,101) tdate,stdStandard std, count(1) tot_students from tbl_students where Convert(varchar(15), TDate,101)='10/18/2011' group by Convert(varchar(15), TDate,101), stdStandard

output is:
Tdate std tot_students
10/18/2011 1 4
10/18/2011 2 1
10/18/2011 3 4
10/18/2011 4 2
10/18/2011 5 1

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Bulksms, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response