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 How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am


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