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

How to pick up rows and put them like columns...

Status
Not open for further replies.

lgf

Programmer
Jul 10, 2001
2
ES
I, I want to handle this select statement as follow:

select
col1,
col2 from table

This select statement return 2 lines:

col1 col2
---- ----
BasketBall 2 points
BasketBall 3 points

Now, i want to use a simple select statement to give me one single row, like this:

col1 col2 col2´
---- ----- ------
BasketBall 2 points 3 points

It's just an example that what i need to SQL do...

Thank's a lot for your help...
 
How about

select col1,
decode(col2, 2 , 2, 0) value_2,
decode(col2, 3 , 3, 0) value_3 from table

Steve
 
You may have figured out what harris79 was trying to do
but here is another view:

select 'col1' Col1,
decode('col2', 2 , 2, 0) Col2,
decode(col2, 3 , 3, 0) Col3 from table
/
with 'col1' being the column name for Basketball as col1 as the alias, col2 being 2 points and col2 being 3 points etc.
sokeh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top