Case function

If i have a Customer table with following data
cust id custname
1 A
2 B

and cars table with following data
car id cust id Model
1 1 Toyota
2 1 Honda
3 2 Suzuki

what is the query to give follwing out put

custid cust name model model 1
1 A Toyota Honda
2 B Suzuki

Questions by amjadkj25

Showing Answers 1 - 15 of 15 Answers

EZESPMAN

  • Aug 6th, 2008
 

create table car_temp select * from cars where Model = "Honda";

select distinctrow a.custid, a.custname, b.Model, c.Model from Customer a, cars b, car_temp c where a.custid = b.custid AND a.custid = c.custid;

me.ranjeet

  • Sep 25th, 2008
 

select cust_id, custname, SYS_CONNECT_BY_PATH(model, ' ') model from ( select a.cust_id, a.custname, b.model, count(*) OVER ( partition by a.cust_id ) cnt, ROW_NUMBER () OVER ( partition by a.cust_id order by null) seq from customer a, car b where a.cust_id=b.cust_id) where seq=cnt start with seq=1 connect by prior seq+1=seq and prior cust_id=cust_id

  Was this answer useful?  Yes

vinayak1234

  • Mar 30th, 2010
 

SELECT c.custid, c.custname, m.model FROM custtable AS c JOIN carstable AS m ON c.custid = m.custidgroup BY c.custid, c.custname, m.model

  Was this answer useful?  Yes

pravintule

  • May 28th, 2010
 

select c.custid,c.custname,m1.model,m2.model as model1 from customer c1,car m1,car m2
where c.custid=distinct(m1.custid) and
            c.custid(+)=m2.custid

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions