Results 1 to 4 of 4

Thread: Query Question

  1. #1
    Join Date
    Sep 2010
    Posts
    14

    Unanswered: Query Question

    This may be a carzy question but here it goes any way:

    Would it be possible to show the same column 3 different times with different data in each column. For example, the way that the programmer created the DB The user enters an event and then a date for the event. A single client may have 8 events. I would like a different column for each event with the date under that, much like an Excel document, showing all events on one line thus have the client name only taking a single line.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    what you're asking for is called a "crosstab" layout

    this is not a task that the database engine should be asked to perform

    to give you a feeling for why, it's because in order to have separate columns for each event, you would have to hardcode the conditional expression for each column in the sql, and this is bloated, awkward and prone to error (i mean, look, you started out talking about 3, then suddenly there were 8...)

    do the crosstab in your application language (php or whatever)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Sep 2010
    Posts
    14
    Thanks for the reply!! I figured that but needed to have "proof" for my supervisors...

    By the way I love your book!!! Almost through it a 2nd time

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    thanks for the kind words

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

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
  •