Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Merge 2 records sancraig16 SYNCSORT 19 Tue Mar 27, 2018 8:17 pm
No new posts Unique IMS DB identifier ashek15 IMS DB/DC 1 Mon Mar 12, 2018 11:45 pm
No new posts Copy set of records based on condition krish.deepu SYNCSORT 2 Thu Mar 08, 2018 11:39 am
No new posts add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 11 Thu Feb 22, 2018 5:37 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us