Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2010
    Posts
    207

    Lightbulb Unanswered: Specific question about an SQL Statement showing attributes at the beginning @new row

    Hello friends,

    does anyone of you know a possibility, to run a SQL query on a table that shows each attribute at the beginning of a new row?

    Attribute1#1 Attribute1#2 Attribute#3
    Value1 Value2 Value3

    Attribute#1 Value1
    Attribute#2 Value2
    Attribute#3 Value3

    thanks in advance.

    the db_n00b.

  2. #2
    Join Date
    Sep 2003
    Location
    United States
    Posts
    65
    Provided Answers: 1
    select name,
    sum(case when color = 'Red' then value else 0 end) Red,
    sum(case when color = 'Green' then value else 0 end) Green,
    sum(case when color = 'Blue' then value else 0 end) Blue
    from
    (
    select color, Paul value, 'Paul' name
    from yourTable
    union all
    select color, John value, 'John' name
    from yourTable
    union all
    select color, Tim value, 'Tim' name
    from yourTable
    union all
    select color, Eric value, 'Eric' name
    from yourTable
    ) src
    group by name
    >>
    >> Learn PHP/MySQL for free https://www.youtube.com/watch?v=mpQts3ezPVg
    >> Free Web Hosting with PHP, MySQL, Website Builder : http://www.000webhost.com/862861.html

  3. #3
    Join Date
    Jan 2010
    Posts
    207
    Thank you, i am going to test that.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •