GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Database  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 136 of 138    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: 2 Last Update: September 26, 2008     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 0Overall Rating: +1    
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

 Related Questions

MONTHS_BETWEEN 
Latest Answer : In SQL 7.0, 2000Select days=datediff(dd,'1-1-2008','1-31-2008')Result 30 days ...

FLOOR 
Latest Answer : TRUNC will give same output as FLOOR ...

Is there any query which is use to find the case sensitivity in each records in database through visual basic?

_______data type is used to store binary data such as graphics, sound, etcSQL uses ____________ clause to impose an order on the result of a query _________ function determines the number of rows or column values.The limit that determines the sphere of influence and control over a system is called_______________ is a graphic technique that can be used by analyst to represent the inputs and outputs.
Read Answers (5) | Asked by : Amit Sharma

Latest Answer : Pipelined functions are useful if there is a need for a data source other than a table in a select statementFor more details, following link is available.http://www.adp-gmbh.ch/ora/plsql/pipeline.html ...
Read Answers (1) | Asked by : tc

Latest Answer :  the translate function replaces a sequence of characters in a string with another set of characters. However, it replaces a single character at a time. For example, it will replace the 1st character in the string_to_replace with the 1st character ...
Read Answers (1) | Asked by : sasi_sql

my script contains sql plus set commands. how to execute that script in a pl/sql block i.e. either anonymous ,procedure or function or trigger 
Latest Answer : First you need to save your file in .sql format, suppose you create set.sql and saved it on c: drive then follow below command.SQL> @C:SET.SQL and press ENTERyour script has been executed. :-) ...

if i have a Customer table with following datacust id custname1 A2 Band cars table with following datacar id cust id Model1 1 Toyota2 1 
Latest Answer : 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 ...

Display details of employees having same char at the star and end postition of their namelike abishikathis name have last character and first character is same 
Latest Answer : Select * FROM TEST WHERE SUBSTR(NAME,1,1)=SUBSTR(NAME,-1,1) ...


 Sponsored Links

 
Related Articles

Using XMLType for Handling XML Data in the Database

Using XMLType for Handling XML Data in the Database Being an object type XMLType can not only be used to store XML data in the database but also to operate on that data via its built in methods Regardless of the storage model you choose XMLType provides a set of XML specific methods to operate on XM
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

Performing XSLT Transformations inside the Database

Performing XSLT Transformations inside the Database Now that you have the employees XSL stylesheet stored in the database and the xmlusr schema is permitted to access the hr employees table you can create a script that will instruct the database to build an HTML page based on the data stored in hr e
 

Moving All the XML Processing into the Database

Moving All the XML Processing into the Database In the preceding example the database server performs only a part of the XML processing while the rest is still performed by the PHP engine Specifically the database server generates an employees XML document based on the records from the hr employees
 

Performing XML Processing inside the Database

Performing XML Processing inside the Database When building XML enabled applications on top of Oracle there are many advantages to performing the XML processing inside the database when compared to performing it on the client The key advantages to perform XML processing inside the database are as fo
 

C++ Pure Virtual Function and Base Class

C Pure Virtual Function and Virtual Base Class In this C tutorial you will learn about pure virtual function declaration of pure virtual function and virtual base class virtual base class and how to implement a virtual base class explained with examples mosgoogle center What is Pure Virtual Function
 

C++ Function Passing Types

C Function Passing Types In this C tutorial you will learn about function passing types two types of arguments passing in functions passed by value  and  passed by reference are discussed here mosgoogle center The arguments passed to a function can be performed in two ways Passed
 

What is Operational Database

Operational Database is the database-of-record, consisting of system-specific reference data and event data belonging to a transaction-update system. It may also contain system control data such as indicators, flags, and counters. The operational database is the source of data for the data warehouse
 

Evolution of database systems

The Evolution of Database systems File Management System Hierarchical database System  Network Database System  Relational Database System File Management System: The file management system also called as FMS in short is one in which all data is stored on a singl
 

What is DECODE function used for?

DECODE is used to decode a CHAR or VARCHAR2 or NUMBER into any of several different character strings or numbers based on value. That is DECODE does a value-by-value substitution. For every value that is given in the DECODE function it makes an if then check and matches the value. The general format
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape