cust id,cust quty like 1,101;1,102;1,103 i want output like
cust id,cust quty 1 101,102,103 in oracle please write a
query in oracle

Answers were Sorted based on User's Feedback



cust id,cust quty like 1,101;1,102;1,103 i want output like cust id,cust quty 1 101,102,103 in ora..

Answer / subhash

PIVOT finction available from ORCLE 11g Onwards:

SELECT *
FROM (SELECT customer_id, customer_quantity
FROM pivot_test)
PIVOT (customer_quantity FOR (customer_quantity
) IN (101, 102, 103))
ORDER BY customer_id;


Output:
1 101 102 103

Is This Answer Correct ?    2 Yes 0 No

cust id,cust quty like 1,101;1,102;1,103 i want output like cust id,cust quty 1 101,102,103 in ora..

Answer / subhash

SELECT
CUST_ID,
DECODE(CUST_ID,'101',CUST_QUTY) AS CUST_QUTY1,
DECODE(CUST_ID,'102',CUST_QUTY) AS CUST_QUTY2,
DECODE(CUST_ID,'103',CUST_QUTY) AS CUST_QUTY3
FROM TABLE_NAME
GROUP BY CUST_ID;

Is This Answer Correct ?    1 Yes 1 No

cust id,cust quty like 1,101;1,102;1,103 i want output like cust id,cust quty 1 101,102,103 in ora..

Answer / srinu

select translate('1,101;1,102;1,103','1,101;1,102;1,103',1
101,102,103) from dual;

Is This Answer Correct ?    3 Yes 9 No

Post New Answer

More Data Stage Interview Questions

What is job control?

0 Answers  


how do u capture duplicates through sort & transformer

4 Answers  


how can or from where we can get reference data in scd type2 implementation?

2 Answers   JPMorgan Chase,


Is there no issue when you try to convert a NOt null column in nullable and vice versa in aggregator styage and transformer stage? When I tried i got the warnings but in a running code I can see such type of scenarios. Please explain

2 Answers  


What is Cleanup Resources and when do you use it?

2 Answers  


source file having the data like aabbccc, i want target file result like a1a2b1b2c1c2c3.

2 Answers  


What is a ds designer?

0 Answers  


I have 2 files 1st contains duplicate records only, 2nd file contains Unique records.EX: File1: 1 subhash 10000 1 subhash 10000 2 raju 20000 2 raju 20000 3 chandra 30000 3 chandra 30000 File2: 1 subhash 10000 5 pawan 15000 7 reddy 25000 3 chandra 30000 Output file:-- capture all the duplicates in both file with count. 1 subhash 10000 3 1 subhash 10000 3 1 subhash 10000 3 2 raju 20000 2 2 raju 20000 2 3 chandra 30000 3 3 chandra 30000 3 3 chandra 30000 3

2 Answers   TCS,


what is the best stage in datastage parller jobs to use full out join and why

5 Answers   Virtusa,


What are data elements?

0 Answers  


If you want to use a same piece of code in different jobs, how will you achieve this?

0 Answers  


which cache supports connected & un connected Lookup

1 Answers   Wipro,


Categories