If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > concatenate the columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-17-04, 13:09
manth manth is offline
Registered User
 
Join Date: Mar 2004
Posts: 54
concatenate the columns

Hi,

My query

select op.bse_optn_num as c1, opt.des ,
op.rspns_cutof_dte,
op.rspns_cutof_tme
FROM TNR241_optn op, TNR244_opt_typ opt
WHERE op.opt_typ_num = opt.num
AND op.annc_smry_id = 2767347
ORDER BY c1;

My result

C1 DES RSPNS_CUTOF_DTE RSPNS_CUTOF_TME
1 Cash 2004-06-17 15:00:00

But i want result as follows

Option Timestamp
1. Cash 2004-06-17 15:00:00

basically i need to concatenate the first 2 columns and last 2 columns some thing like this
select op.bse_optn_num ||'. ' || opt.des as Option ,
op.rspns_cutof_dte ||' '||op.rspns_cutof_tme as Timestamp
FROM TNR241_optn op, TNR244_opt_typ opt
WHERE op.opt_typ_num = opt.num
AND op.annc_smry_id = 2767347
ORDER BY Option;

This will work in Oracle, but it is not working with DB2

How do we do this?

I appreciate ur help.

Thanks

Last edited by manth; 08-17-04 at 13:47.
Reply With Quote
  #2 (permalink)  
Old 08-17-04, 14:52
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What are the data types of:
op.bse_optn_num, opt.des, op.rspns_cutof_dte, and op.rspns_cutof_tme?

Andy
Reply With Quote
  #3 (permalink)  
Old 08-17-04, 14:52
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
What data type is the op.bse_optn_num? If it is numeric, you might consider casting it as Character in order to concatenate.
Reply With Quote
  #4 (permalink)  
Old 08-17-04, 14:53
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
What data type is the op.bse_optn_num? If it is numeric, you might consider casting it as Character in order to concatenate. Do the same with the timestamp.
Reply With Quote
  #5 (permalink)  
Old 08-17-04, 15:02
manth manth is offline
Registered User
 
Join Date: Mar 2004
Posts: 54
Here you go

bse_optn_num: SMALLINT
des: CHAR
RSPNS_CUTOF_DTE: DATE
RSPNS_CUTOF_TME: TIME

Thanks
Reply With Quote
  #6 (permalink)  
Old 08-17-04, 16:32
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
Try something like this:

select char(op.bse_optn_num) ||'. ' || opt.des as Option ,
char(op.rspns_cutof_dte) ||' '||char(op.rspns_cutof_tme) as Timestamp
FROM TNR241_optn op, TNR244_opt_typ opt
WHERE op.opt_typ_num = opt.num
AND op.annc_smry_id = 2767347
ORDER BY Option;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On