Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql querry

 
sushil pandey
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a staff table like this:

name year salary
============================
a 1998 50
a 1999 100
a 2000 200
a 2001 300
b 2000 200
b 2001 300


I want to get a new table from the above table:

name salary(1998) salary(1999) salary(2000) salary(2001)
===================================================================
a 50 100 200 300
b 0 0 200 300

NB-no of years may increase over time so it should be a generic code
What's the SQL for this problem? I will invoke the sql code in my java code.
Thanks.
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the SQL you have tried so far ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sushil,
I'm moving this to JDBC (near the top of the forum list) since it is more of a sql question than an oracle specific one.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like a school assignment since you and George both posted the same question, so I'm just going to give a hint: look into subqueries, unions and joins. It's quite complex sql.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic