View previous topic :: View next topic |
Author |
Message |
arvibala Beginner
Joined: 12 Feb 2008 Posts: 142 Topics: 67
|
Posted: Fri Sep 24, 2010 7:48 am Post subject: Better SELECT statement for DISTINCT |
|
|
Sample Table
Code: |
A B C D
1 2 3 4
1 3 4 5
2 1 2 3
1 2 3 4
2 2 2 2
|
Query
Code: |
SELECT DISTINCT(A), B, C, D from TABLE
|
I was expecting this to return
But it returned
Code: |
1 2 3 4
1 3 4 5
2 1 2 3
2 2 2 2
|
the DISTINCT applied to all column names .... but when I did the same using CURSOR ... it gives the expected results.
What should be the proper SELECT statement?[/code] _________________ Arvind
"You can make a difference with your smile. Have that with you always" |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Sep 24, 2010 10:30 am Post subject: Re: Better SELECT statement for DISTINCT |
|
|
arvibala wrote: |
the DISTINCT applied to all column names .... but when I did the same using CURSOR ... it gives the expected results. |
You mean to say the program and spufi gives you different results?
Kolusu |
|
Back to top |
|
|
arvibala Beginner
Joined: 12 Feb 2008 Posts: 142 Topics: 67
|
Posted: Mon Sep 27, 2010 4:37 am Post subject: |
|
|
Yes ... Select and Fetch gave us diff results ..... _________________ Arvind
"You can make a difference with your smile. Have that with you always" |
|
Back to top |
|
|
papadi Supermod
Joined: 20 Oct 2009 Posts: 594 Topics: 1
|
Posted: Mon Sep 27, 2010 1:32 pm Post subject: |
|
|
It will probably help if you post the SELECT, the CURSOR definition, and the FETCH. _________________ All the best,
di |
|
Back to top |
|
|
|
|