Home » SQL & PL/SQL » SQL & PL/SQL » Odd Select Query
Odd Select Query [message #326822] Thu, 12 June 2008 14:14 Go to next message
jameswise
Messages: 8
Registered: August 2006
Junior Member
I have a table (t_machines) with the following fields and records:
c_machine c_style
1 A
2 A
3 B
4 A

I would like to query this table and return data about which machines are running which style. For example:

Style Machines
A 1,2,4
B 3

I can return all the records from the table but I don't know of a way to have a single record with a field show me all the machines running a given style.

If anyone knows of a way to do this, I would really appreciate it!
Re: Odd Select Query [message #326823 is a reply to message #326822] Thu, 12 June 2008 14:26 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Search for "pivot", this is asked several times each week.

In addition, please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

And always post a test case: create table and insert statements, along with the result you want with these data.

Regards
Michel
Re: Odd Select Query [message #326831 is a reply to message #326823] Thu, 12 June 2008 15:25 Go to previous messageGo to next message
jameswise
Messages: 8
Registered: August 2006
Junior Member
Michel,

Thanks for your reply. I didn't know what to search for and was just posting quickly with some information hoping that someone could point me in the right direction. You did that and I am able to handle what I was after now. Thanks for your help.

Regards,
James
Re: Odd Select Query [message #326901 is a reply to message #326831] Fri, 13 June 2008 00:45 Go to previous message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It is a fair practice to post the solution you find in order to help future readers.

Regards
Michel
Previous Topic: Problem with GROUP BY
Next Topic: decode script
Goto Forum:
  


Current Time: Thu Dec 08 22:32:47 CST 2016

Total time taken to generate the page: 0.08719 seconds