Thread: Join Help

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

    Join Date
    May 2009
    Rep Power

    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
    Toronto Canada
    Rep Power
    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 | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo