Thread: Join Help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    5
    Rep Power
    0

    Exclamation Join Help


    I have a table that contains info:

    id, date, amount, amountType

    amountType has 3 valid values (1, 2, 3)

    I would like to create a statement that returns

    id, date, amount (where amount type = 1), amount (where amount type = 2) amount (where amount type = 3)

    In reality, the table and data are more complex, but I can't get the simpler scenario to work. This isn't really that difficult, is it?

    Thanks for any input...
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,026
    Rep Power
    4210
    Originally Posted by mkswanson
    In reality, the table and data are more complex
    thanks for being honest

    nobody is going to want to write sql for you knowing that it's not your real scenario

    besides, this type of cosmetic re-arrangement, which is usually called pivoting if you want to research it, should actually be done in your front-end application language, not with sql
    r937.com | rudy.ca
    please visit Simply SQL and buy my book

IMN logo majestic logo threadwatch logo seochat tools logo