Rajkumar R

Rajkumar R

  • NA
  • 183
  • 215.7k

Sqlserver query

Oct 27 2012 2:14 AM
I have i table like this with values

Acall1     Acall2     Acall3... Acall6    Icall1   icall2... iCall6     Login Salesrep
23/10/2012 23/10/2012 23/10/2012 23/10/2012 2/2/2012 2/2/2012  2/2/2012  PL   Paul
null      2/2/20112 null      2/2/20112 2/2/20112 2/2/20112 null         PL   Paul
2/2/20112 2/2/20112 2/2/20112 2/2/20112 2/2/20112 2/2/20112 2/2/20112    AN   Answer
2/2/20112 2/2/20112 2/2/20112 2/2/20112 2/2/20112 2/2/20112 2/2/20112    CM   Campel
2/2/20112 2/2/20112 2/2/20112 2/2/20112 2/2/20112 2/2/20112 2/2/20112    MU   Merry
23/10/2012 23/10/2012 23/10/2012 23/10/2012 2/2/20112 2/2/20112 2/2/20112 PL  ALex

I need output for last seven days any of the Acall or Icall havinig ast seven days.

Output. This for Admin login
salesrep oct20 oct21 oct22 oct23 oct24 oct25 oct26
Paul      0     0     0     4     0     0     0
Answer    0     0     0     0     0     0     0
Campel    0     0     0     0     0     0     0
Merry     0     0     0     0     0     0     0
Alex      0     0     0     4     0     0     0

Here PL login have two sales reps i want to show this in two different rows.
If i login as PL then it should show where salesrep=paul and ALEX in tow rows.

FOR PL Login Sample output like this..
salesrep oct20 oct21 oct22 oct23 oct24 oct25 oct26
Paul      0     0     0     4     0     0     0
Alex      0     0     0     4     0     0     0

Please post solution for this.
Thanks in advance