Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Concatenating Strings with Unique records in SQL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Concatenating Strings with Unique records in SQL
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    Post subject:
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    Post subject: Reply to: Concatenating Strings with Unique records in SQL
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us