GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Database  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 136 of 139    Print  
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



  
Total Answers and Comments: 3 Last Update: November 05, 2009     Asked by: amjadkj25 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: EZESPMAN
 
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;

Above answer was rated as good by the following members:
h.karamshil
August 06, 2008 09:01:36   #1  
EZESPMAN Member Since: August 2008   Contribution: 2    

RE: Case function
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;

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 1Overall Rating: -N/A-    
September 25, 2008 07:46:48   #2  
me.ranjeet Member Since: September 2008   Contribution: 3    

RE: Case function
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
 
Is this answer useful? Yes | No
November 05, 2009 01:43:25   #3  
mukesh mansane Member Since: October 2008   Contribution: 3    

RE: Case function
select * Customer Car
where Customer.custID Car.custID;

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape