Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2006

    Unanswered: Problem with a select distinct

    I have a problema with a select distinct, I have the next sql:

    select distinct a,b,c,d from (select a,b,c,d,e,f...from table where ...)

    The subselect have 25000 rows, it last about 10 seconds, but the select distinct over the subselect takes a long time..., I have waited for 20 minutes, and finally canceled the sql.

    When I make this alternative path:

    create table2 as (select a,b,c,d,e,f...from table where ...)
    select distinct a,b,c,d from table2

    The distinct finish in 5 seconds.

    I don't understand the differences.... I can't do the alternative path, I need the first sql to work.
    I don''t know where is the problem

    Any advice will be greatly appreciatted

  2. #2
    Join Date
    Jan 2004
    Croatia, Europe
    Provided Answers: 4
    Why do you select "a, b, c, d, e, f" from a table if you need only distinct "a, b, c, d"? In other words, why not directly
    select distinct a, b, c, d 
    from table

Posting Permissions

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