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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select query transformation 1

Status
Not open for further replies.

Andyfives

Programmer
Feb 22, 2002
46
DK
Hi there folks,

I have a small problem that I can not seem to fix and just need some guidence to get started.

Simplified problem

My source table:-

Table1
PNRS SEGID PAXID FLIGHTDATE
ABC 1 1 10/12/2004
DEF 1 1 11/12/2004
DEF 1 2 11/12/2004
DEF 2 1 19/12/2004
DEF 2 2 19/12/2004
GHI 1 1 05/01/2005
GHI 2 1 07/01/2005

needs a select query that transformd it to:-

PNRS DEPARTURE_DATE RETURN_DATE
ABC 10/12/2004
DEF 11/12/2004 19/12/2004
GHI 05/01/2005 07/05/2005

My usual thing to do is just create some VB code and change as I like there, but I really need to get out of doing this everytime. Can anyone help me?

What command do I need to look up?

BTW MySQL Maestro really is good. I'm beginning to find my way around. I recommend it.

Thank you in advance
Andy
 
Code:
select PNRS 
     , min(FLIGHTDATE) as DEPARTURE_DATE 
     , max(FLIGHTDATE) as RETURN_DATE
  from Table1
group
    by PNRS

rudy
SQL Consulting
 
Just found the group_concat funtion too but this could work better.

Thanks for your response. I'll give it a try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top