aspose file tools*
The moose likes JDBC and the fly likes SQL question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

SQL question?

George Liao
Greenhorn

Joined: May 20, 2003
Posts: 14
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


What's the SQL for this problem? I will invoke the sql code in my java code.
Thanks.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30972
    
159

George,
Sushil posted the exact same question. I'm closing this (I picked one randomly) so that all the discussion can continue in one place.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL question?