sql server 2008 - Generate SQL query for all datewise for each employee -


i have 2 table -

tbl1

owner_id owner_name


  1           2         b   3         c 

tbl2

can_id   can_name   owner_id   createddate    ------------------------------------------     11        aa     1          10/3/2014 12        bb     2          9/3/2014 13        cc     3          8/3/2014  14        dd     3          7/3/2014 15        ee     2          9/3/2014 16        ff     1          5/3/2014 17        gg     2          4/3/2014 

i want result this:

createdate                                     b                  c         ----------------------------------------------------------------------     1/3/2014               0                        0                   0 2/3/2014               0                        0                   0 3/3/2014               0                        0                   0 4/3/2014               0                        1                   0 5/3/2014               1                        0                   0 6/3/2014               0                        0                   0 7/3/2014               0                        0                   1 8/3/2014               0                        0                   1            9/3/2014               1                        2                   0 10/3/2014              0                        0                   0 11/3/2014              0                        0                   0 

date passed dynamically, 1 31st , have count records datewise of each employee?

enter image description here

you can see , understand .its self explanatory. using pivot , unpivot can overcome problem.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -