|
naresh0407
Starting Member
30 Posts |
Posted - 2010-11-18 : 07:35:21
|
| Hi All,This is my table and query.When i run the query i am getting EmpName,Dates and Time.Now i want Dates as header and corresponding Time for that date as row value.I am trying to get reports like thisEmpName 10/3/2010 10/4/2010 10/5/2010 10/6/2010 10/7/2010 10/8/2010 10/9/201Naresh 17:00 14:00 ..........CREATE TABLE TestTable(EmpNo int,EmpName varchar(20), atndate DATETIME, StartTime varchar(50),EndTime varchar(50),MatchingOff varchar(20),CampaignID int )SET IDENTITY_INSERT mytable ONInsert into TestTable(EmpNo,EmpName,atndate,StartTime,EndTime,MatchingOff,CampaignID)select '3','NareshNadimpalli','10/3/2010','0','0','Off','3' union allselect '3','NareshNadimpalli','10/4/2010','7:30 AM','6:00 PM','07:30 ','3' union allselect '3','NareshNadimpalli','10/5/2010','0','0','Off','3' union allselect '3','NareshNadimpalli','10/6/2010','7:30 AM','7:30 AM','07:30 ','3' union allselect '3','NareshNadimpalli','10/7/2010','7:30 AM','7:30 AM','07:30 ','3' union allselect '3','NareshNadimpalli','10/8/2010','7:30 AM','7:30 AM','07:30 ','3' union allselect '3','NareshNadimpalli','10/9/2010','7:30 AM','7:30 AM','07:30 ','3' union allselect '2','ALETARIDINGER','10/3/2010 12:00:00 AM','0','0','Off','1' union allselect '2','ALETARIDINGER','10/4/2010 12:00:00 AM','7:30 AM','6:00 PM','07:30 ','1' union allselect '2','ALETARIDINGER','10/5/2010 12:00:00 AM','0','0','Off','1' union allselect '2','ALETARIDINGER','10/6/2010 12:00:00 AM','7:30 AM','7:30 AM','07:30 ','1' union allselect '2','ALETARIDINGER','10/7/2010 12:00:00 AM','7:30 AM','7:30 AM','07:30 ','1' union allselect '2','ALETARIDINGER','10/8/2010 12:00:00 AM','7:30 AM','7:30 AM','07:30 ','1' union allselect '2','ALETARIDINGER','10/9/2010 12:00:00 AM','7:30 AM','7:30 AM','07:30 ','1' union allselect '2','ALETARIDINGER','10/17/2010 12:00:00 AM','0','0','Off','1' union allselect '2','ALETARIDINGER','10/18/2010 12:00:00 AM','7:30 AM','6:00 PM','07:30 ','1' union allselect '2','ALETARIDINGER','10/19/2010 12:00:00 AM','0','0','Off','1' union allselect '2','ALETARIDINGER','10/20/2010 12:00:00 AM','7:30 AM','7:30 AM','07:30 ','1' union allselect '2','ALETARIDINGER','10/21/2010 12:00:00 AM','7:30 AM','7:30 AM','07:30 ','1' union allselect '2','ALETARIDINGER','10/22/2010 12:00:00 AM','7:30 AM','7:30 AM','07:30 ','1' union allselect '2','ALETARIDINGER','10/23/2010 12:00:00 AM','7:30 AM','7:30 AM','07:30 ','1' Select empno,empname,atndate,starttime +'-'+Endtime as EmpTime from TestTablewhere atndate>='09/26/2010' and atndate<='10/16/2010' and matchingoff<>'Off'and empno not in(Select empno from TestTable where atndate between '10/17/2010' and '10/24/2010'and matchingoff='Off' group by empno) |
|