MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Better SELECT statement for DISTINCT

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Fri Sep 24, 2010 7:48 am    Post subject: Better SELECT statement for DISTINCT Reply with quote

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

Code:

1 2 3 4
2 1 2 3


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
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Fri Sep 24, 2010 10:30 am    Post subject: Re: Better SELECT statement for DISTINCT Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Mon Sep 27, 2010 4:37 am    Post subject: Reply with quote

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
View user's profile Send private message Yahoo Messenger
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Mon Sep 27, 2010 1:32 pm    Post subject: Reply with quote

It will probably help if you post the SELECT, the CURSOR definition, and the FETCH.
_________________
All the best,

di
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group