Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query to create view

Status
Not open for further replies.

chrismcaniff

Programmer
May 18, 2006
8
0
0
US
Hi,
I have one table called comments that looks like this

recordno lineno comment
100 1 Joe Smith
100 2 Room 408

I cannot modify this table but would like to create a view which looks like this:

recordno guestname roomno
100 Joe Smith Room 408

Does anyone know how to write a SQL Query for This ?
 
Code:
select recordno
     , max( case when lineno=1
                 then comment
             end ) as guestname
     , max( case when lineno=2
                 then comment
             end ) as roomno
  from comments
group
    by recordno

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top