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 

Getting Distinct values on 3 columns

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


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Mon Feb 12, 2007 6:22 am    Post subject: Getting Distinct values on 3 columns Reply with quote

I have a DB2 query and i am selecting columns like below:
Code:

 SELECT EMPNO,EMPNAME,HIKEDATE FROM A
 WHERE HIKEDATE = 1;                             

I am getting the output as :
Code:

1   A   1
2   B   1
2   B   1

What i want is i want to eliminate duplicate records in the table and i want the output as.Is there any query to get the desired results.
Code:

1   A   1
2   B   1
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Mon Feb 12, 2007 6:34 am    Post subject: Reply with quote

SELECT DISTINCT(EMPNO, EMPNAME, HIKEDATE)
FROM A
WHERE HIKEDATE = 1
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Mon Feb 12, 2007 1:30 pm    Post subject: Reply with quote

Dick,

I am getting SQL error -104 .Is it possible to have DISTINCT for more than 1 column in a Single Query ? Please help me out in the correct Query:
Code:

SELECT DISTINCT(EMPNO, EMPNAME, HIKEDATE)
FROM A
WHERE HIKEDATE = 1

Code:

QUERY MESSAGES:                                 
SQL error at or before ,  (line 1, position 22).
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Mon Feb 12, 2007 1:43 pm    Post subject: Reply with quote

yadav2005,

Remove the brackets and try like this

Code:

SELECT DISTINCT EMPNO,EMPNAME,HIKEDATE
  FROM A                             
 WHERE HIKEDATE = 1;                   


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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