Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Two records to appear on the same line

Author  Topic 

tanu
Yak Posting Veteran

57 Posts

Posted - 2008-06-25 : 17:21:41
Hi,
I have this college list. I need two records appearing on the same line if their textterm,department,course and section matches.
Then there would be three more columns Offerday2, TimeFrom2,
Time2.


If term,department,course,section are same we see like this now
Term Department course section Title offerday starttime endtime

FAll08 a 1 2 ch MWF 8:00 AM 8:50 AM
FAll08 a 1 2 ch T 1:00 PM 3:30 PM


But we want something like this

Term Department course section Title offerday starttime endtime offerday2 Starttime2 endtime

FAll08 a 1 2 ch MWF 8:00 AM 8:50 AM T 1:00 pm 3:30 pm


Select TextTerm,Department,Course, Section, Coursename as Title,Credits,OfferDays,
TimeFrom = (Select case when offerdays = ' ' then 'N/A'
Else left(STUFF(right(CONVERT(varchar(50), offertimefrom, 109), 14), 9, 4, ' '),5)+' '+
right(STUFF(right(CONVERT(varchar(50), offertimefrom, 109), 14), 9, 4, ' '),2) End) ,
TimeTo = (Select case when offerdays = ' ' then 'N/A'
Else left(STUFF(right(CONVERT(varchar(50), offertimeTo, 109), 14), 9, 4, ' '),5)+' '+
right(STUFF(right(CONVERT(varchar(50), offertimeTo, 109), 14), 9, 4, ' '),2) End),
convert(varchar(10),StartDate,101)as StartDate, convert(varchar(10),EndDate,101) as EndDate, FacultyFirstName+' '+FacultyLastName as Instructor,
MaximumEnroll as Limit, CurrentEnroll as Enrolled, RoomAbbreviation, RoomNumber,AccessCampus,Status from View
where TextTerm ='Fall08' and MaximumEnroll > CurrentEnroll

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-25 : 17:57:19
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -