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

Have a flat result?

Status
Not open for further replies.

inarobis

IS-IT--Management
Apr 3, 2006
71
0
0
CH
Hello guys,

I would like to have a flat result of this query result.

This is my result doing my normal query with left join and inner join throught tables (PHONE, PERSON, EMAIL, ADDRESS )


Phone eMail City Fax
Mariam 2135262 NULL NULL NULL
Mariam NULL mari@mari.na NULL NULL
Mariam NULL NULL Napoli NULL
Mariam NULL NULL NULL NULL


How can I have this result?

Phone eMail City Fax
Mariam 2135262 mari@mari.na Napoli NULL


thanks on advance

Ina
 
Hi there,

What you are looking for is the MAX function. Try this:

Code:
SELECT Name_Field,
       MAX(Phone),
       MAX(eMail),
       MAX(City),
       MAX(Fax)
FROM (Tables and Joins here)
GROUP BY Name_Field

You may run into problems with this approach if there is more than one person with the same name on your tables. In this case you may get Phone, email, city or fax details from the wrong person if their 'value' is larger than that of the person you actually want to return


Geraint

The lights are on but nobody's home, my elevator doesn't go to the top. I'm not playing with a full deck, I've lost my marbles. Barenaked Ladies - Crazy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top