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
 General SQL Server Forums
 New to SQL Server Programming
 Single row result from mutliple table rows?

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-09-19 : 12:03:46
Hi again,

I'd appreciate advice on the following. Thanks very much!

Given this Table:
family|product|type
fam1 |abc |XX
fam1 |def |YY

What query would return this?
Family|Type1|Type2
fam1 |xx |yy


--PhB

X002548
Not Just a Number

15586 Posts

Posted - 2007-09-19 : 12:06:32
Here, read this

http://weblogs.sqlteam.com/brettk/archive/2005/02/23/4171.aspx



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-09-19 : 12:22:01
Thanks for the quick reply!

That page shows a lot of stuff I don't need, I just want a simple query. Is it safe to say that the COALESCE command is the one that does what I need?

Also, family field is not necessarily the key.

Thanks!



--PhB
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-19 : 12:30:53
What is then?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-09-19 : 12:40:20
Just want a query result to be this:
fam1,xx,yy

The pipes were just there are visual field separators.

Just want query results to show on one line instead of two.

--PhB
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-09-19 : 12:41:14
If you are looking for a Cross Tab then

See: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=Pivot+table2,Pivot+table,Dynamic+CrossTabs,Dynamic+Cross-Tabs

Kristen
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-19 : 12:42:05
Brett showed you a solution.
Don't you care finding it?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-09-19 : 12:53:37
I feel so, so...unwanted

boo hoo

Someone pass me a margarita



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-09-19 : 12:57:12
quote:
Originally posted by Kristen

If you are looking for a Cross Tab then

See: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=Pivot+table2,Pivot+table,Dynamic+CrossTabs,Dynamic+Cross-Tabs

Kristen



Yes that's it! Thanks for the patient reply to us novices.

--PhB
Go to Top of Page
   

- Advertisement -