| Author |
Topic |
|
pssumesh2003
Starting Member
35 Posts |
Posted - 2010-02-16 : 00:46:39
|
| Hi All,I have a table to store timesheet,table structure is given belowId ,weeKNo,SiteId,EmPId,S,Su,M,T,W,Th,F,Wage,totalWage,Advance,ExtraHere Week No is an integer,S,Su,M,T,W,Th,F numeric(18,0) to store No of Work done by Employ of Id (EmpId) in Site (SiteId) for S(Saturday),Su(Sunday),---F(friday) of the Week (WeekNo) . For WeekNo=1S was 2/1/2010(dd/MM/yyyy).Now i want a report for a Site LikeDate Work2/1/2010 25.54/1/2010 105/1/2010 126/1//2010 15..15/2/2010 20where Date Corespond(S,...F) Work Sum(S)..Sum(F) groupby SiteId,weeknoHow will get this in a select query?Please help me |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-16 : 00:50:21
|
| does weekno represent week number of year or is it week within month?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
pssumesh2003
Starting Member
35 Posts |
Posted - 2010-02-16 : 01:00:23
|
| WeekNo represents WeekNo in a year. Every saturday it incriments by 1i think date for S can calculate like dateadd(dd,(WeekNo*7+0),'2/1/2010').my problem is how can query create |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-16 : 01:23:36
|
quote: Originally posted by pssumesh2003 WeekNo represents WeekNo in a year. Every saturday it incriments by 1i think date for S can calculate like dateadd(dd,(WeekNo*7+0),'2/1/2010').my problem is how can query create
this should give you a startSELECT weeKNo,SiteId,EmPId,Work,DaysFROM(SELECT weeKNo,SiteId,EmPId,S,Su,M,T,W,Th,F FROM Yourtable) tUNPIVOT(Work FOR Days IN ([S],[Su],[M],[T],[W],[Th],[F]))u ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
pssumesh2003
Starting Member
35 Posts |
Posted - 2010-02-16 : 01:38:15
|
| Thank u Very nuch visakh16.This is the solution i really want.once again thank u |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-16 : 02:11:10
|
welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|