0

I have following information stored in a table:

       Id Userd_Fk      CheckIn                 CheckOut          Hours         Day      Date

        12  2   2014-05-15 10:36:42.163 2014-05-15 10:36:45.250 0.0000000000    Sunday  2014-05-15
        13  3   2014-05-15 10:38:10.537 2014-05-15 10:38:39.720 0.0100000000    Monday  2014-05-15
        14  3   2014-05-15 10:39:14.947 2014-05-15 10:39:18.347 0.0000000000    Tuesday 2014-05-15
        15  2   2014-05-15 00:00:00.000 2014-05-15 11:33:20.083 11.5600000000   Wednesday   2014-05-15
        16  4   2014-05-15 11:33:22.730 2014-05-15 11:33:25.073 0.0000000000    Thursday    2014-05-15
        18  5   2014-05-15 11:42:30.497 2014-05-15 11:48:18.763 0.1000000000    Thursday    2014-05-15

table Structure is :

 CheckInCheckOutId  Id
 UserId_Fk  int 
 CheckIn    datetime    
 CheckOut   datetime    
 CountHours nvarchar(50)    
 Day    nvarchar(50)    
 GetDate    date    

Is it possible to get a gridview as following? if yes , how to achieve this?

     Sunday   Monday  Tuesday  Wednesday  Thursday Friday  Saturday  Sunday   Monday  Tuesday  Wednesday  Thursday Friday  Saturday 

1    5.555    6.000    6.000    6.000      6.000   6.000    6.000    6.000    6.000    6.000    6.000     6.000    6.000    6.000 
2    5.555    6.000    6.000    6.000      6.000   6.000    6.000    6.000    6.000    6.000    6.000     6.000    6.000    6.000
3    5.555    6.000    6.000    6.000      6.000   6.000    6.000    6.000    6.000    6.000    6.000     6.000    6.000    6.000
4    5.555    6.000    6.000    6.000      6.000   6.000    6.000    6.000    6.000    6.000    6.000     6.000    6.000    6.000
5    5.555    6.000    6.000    6.000      6.000   6.000    6.000    6.000    6.000    6.000    6.000     6.000    6.000    6.000

where 1, 2, 3.. are UserId_Fk

SQL SERVER 2008 R2

gunr2171
  • 16,104
  • 25
  • 61
  • 88

1 Answers1

0

you should use pivot tables.

for more information check below

Create Pivoted Tables in 3 Steps

or check this stack overflow question

PIVOT on Common Table Expression

good luck

Community
  • 1
  • 1
Aqil
  • 360
  • 2
  • 16