IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Concatenating Strings with Unique records in SQL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
karthikbabudh

New User


Joined: 08 Sep 2003
Posts: 32
Location: Toronto <-> Bangalore

PostPosted: Sat Dec 01, 2007 11:11 pm
Reply with quote

Hi,

I have to append the string "DSNAME" for all the unique records in a field. The output should look like
---------+---------+
REQ_ID
---------+---------+
DSNAME 23407
DSNAME 185131
DSNAME 473890
DSNAME 536686

I used the query "SELECT 'DSNAME', DISTINCT REQ_ID FROM EXPLORE;
But I' am getting "DISTINCT IS NOT A COLUMN OF AN INSERTED TABLE" error.
My query is working if I remove "DISTINCT" keyword, but I' am getting duplicates. I want only the unique records. Can anyone help me?

Thanks,
Karthik.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Sat Dec 01, 2007 11:14 pm
Reply with quote

You can't do distinct on one column only it is on the whole selected column set.

Try this

Code:

SELECT DISTINCT 'DSNAME', REQ_ID
FROM EXPLORE;
Back to top
View user's profile Send private message
karthikbabudh

New User


Joined: 08 Sep 2003
Posts: 32
Location: Toronto <-> Bangalore

PostPosted: Sat Dec 01, 2007 11:23 pm
Reply with quote

Thanks a lot Steve.

Karthik
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top