Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2009
    Posts
    4

    Unanswered: retrieve distict rows

    A hard coded query ..gives me reult as

    Name Number Category Characteristics
    54Raw 540 Toy Black,cold
    54Raw 540 Toy Black, cold,
    64Jay 238 Stick White, Moderate,
    99TV 454 Ball Red, Hot

    (It might not be getting displayed right but the last column named Characteristics contains a pair value ( Black, cold). yes it might be against normalized table)
    I want to retrieve distict rows.


    Name Number Category Characteristics
    54Raw 540 Toy Black,cold
    64Jay 238 Stick White, Moderate,
    99TV 454 Ball Red, Hot


    The thing is if a duplicate row is returned by the hard coded query than all its columns are same,


    How can I get distict rows,
    I cannot alter this hard coded query but can use it as subquery.

    I do not want to store its results in a table and than use it,

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    SELECT DISTINCT * FROM ( your query here ) AS q

    one of the very few times it is perfectly okay to use the dreaded, evil "select star"

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

  3. #3
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    I'm not sure what you mean by a "hard coded query". If you can create a new query that contains it as a subquery then why not create a new query entirely that returns the right result?

    The best answer is to change the query so that it won't return duplicate rows. Since we don't know what tables and keys are involved or what the query looks like it's impossible to say how.

Posting Permissions

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