C05B-2016 – CSKC
Sign In

Search





Q&A #6189 siteicon  

Question:

Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables
Table: VEHICLE

CODE VTYPE PERKM
101 VOLVO BUS 160
102 AC DELUXE BUS 150
103 ORDINARY BUS 90
105 SUV 40
104 CAR 20

Note:
– PERKM is Freight Charges per kilometer
– VTYPE is Vehicle Type
Table: TRAVEL

NO NAME TDATE KM CODE NOP
101 Janish Kin 2015-11-13 200 101 32
103 Vedika Sahai 2016-04-21 100 103 45
105 Tarun Ram 2016-03-23 250 102 42
102 John Fen 2016-02-13 90 102 40
107 Ahmed Khan 2015-01-10 75 104 2
104 Raveen 2016-05-28 80 105 4
106 Kripal Anya 2016-02-06 200 101 25

Note:
– NO is Traveller Number
- KM is Kilometer travelled
– NOP is number of travellers travelled in vehicle
- TDATE is Travel Date

(i) To display NO, NAME, TDATE from the table TRAVEL in descending order of NO.

(ii) To display the NAME of all the travellers from the table TRAVEL who are traveling by vehicle with code 101 or 102.

(iii) To display the NO and NAME of those travellers from the table TRAVEL who
travelled between ’2015-12-31′ and ’2015-04-01’.

(iv) To display all the details from table TRAVEL for the travellers, who have
travelled distance more than 100 KM in ascending order of NOP.

(v) SELECT COUNT(*),CODE FROM TRAVEL
GROUP BY CODE HAVING COUNT(*)>1;

(vi) SELECT DISTINCT CODE FROM TRAVEL;

(vii) SELECT A.CODE,NAME,VTYPE
FROM TRAVEL A,VEHICLE B
WHERE A.CODE=B.CODE AND KM<90;

(viii) SELECT NAME,KM*PERKM
FROM TRAVEL A,VEHICLE B
WHERE A.CODE=B.CODE AND A.CODE=’105’;

Answer:

(i) SELECT NO, NAME, TDATE FROM TRAVEL
ORDER BY NO DESC;

(ii) SELECT NAME FROM TRAVEL
WHERE CODE=’101′ OR CODE=’102′;
OR
SELECT NAME FROM TRAVEL
WHERE CODE=101 OR CODE=102;

(iii) SELECT NO, NAME from TRAVEL
WHERE TDATE >= ‘2015-04-01’ AND TDATE <= ‘2015-12-31’;
OR
SELECT NO, NAME from TRAVEL
WHERE TDATE BETWEEN ‘2015-04-01’ AND ‘2015-12-31’;
OR
SELECT NO, NAME from TRAVEL
WHERE TDATE <= ‘2015-12-31’ AND TDATE >= ‘2015-04-01’;
OR
SELECT NO, NAME from TRAVEL
WHERE TDATE BETWEEN ‘2015-12-31’ AND ‘2015-04-01’ ;

(iv) SELECT * FROM TRAVEL
WHERE KM > 100 ORDER BY NOP

(v)
COUNT(*)    CODE
2                     101
2                     102

(vi)
DISTINCT CODE
101
102
103
104
105

(vii)
CODE   NAME     VTYPE
104      Ahmed     Khan CAR
105      Raveena   SUV

(viii)
NAME      KM*PERKM
Raveena   3200


Share

C. Sir| Created: 10-Jan-2019 | Updated: 20-May-2026|CBSE12D-2016









×
ssignment Introductory Sessions Beginning to Program Tokens Keyword and Identifiers Data Types Variables and Constants Operators Simple User Input Building Expressions and Formulas Simple Real World Problems Simple If and If Else Multiple-Nested-Ladder of If Else Switch case selection Simple Loops Tricks in Loops - break continue scope Loop Applications - Handling numerals Series printing loops Nested Loops Pattern printing loops Number Varieties and Crunches String Handling (Null Terminated) Strings - string class type Functions (Built-in) Functions - user defined Functions Reference Passing/Returning Arrays Concepts and 1-D Arrays Array Data Management Two dimensional arrays and Matrices Structures Basics Structures passing/returning Display Using IO Manipulation User Defined Data Types Enumerated Types Preprocessor Directives And Macros Programming Paradigms and OOPs Advantages Abstraction and Encapsulation Polymorphism Inheritance Function Overloading Concepts Function Overloading Varieties Defining Classes Creating and Using Class Objects Class Members Accessibility Class Function Types Inline Functions Constructor Concepts Default Constructor Copy Constructor Constructor Overloading Destructors Inheritance Fundamentals Public Derivations Private and Protected Derivations Multiple Inheritance Mult-Level Inheritance Data File Concepts Handling Text Files Handling Binary Files Pointer Concepts Pointer and Arrays Stacks Queues Introductory Sessions Beginning to Program Tokens Keywords Identifiers Literals Data Types Variables and Constants Operators (Arithmetic-Assignment-Unary-Relational-Logical) Expressions Statements and Formula Based Calculations Class Object Creation and Access Wrapper Classes Constructor Basics Conversion and Checking Functions Math Functions Function building and calling Simple If and If-Else Selection Switch Based Selections Basic Loop Types Array Basics Array Search Array Sorting Character Handling String Basics String Class Functions Types of Errors Try Catch Introductory Sessions Beginning to Program Introductory Sessions Beginning to Program Introductory Sessions Beginning to Program Data Types Variables and Constants Introductory Sessions Beginning to Program Date and Time Handling Regular Expressions Command Line Arguments Concurrent Execution Making Executable File Python Introduction (Features Python Introduction (Features, Installation, Modes) Handling Unicode Internet Interactions Imaging and Compression Special Data File Handling Python Basics Cryptography Blockchain and Cryptocurrency Generative AI keywords, identifiers, variables Beginning To Program Tokens, Keywords, Identifiers Variables and Expressions Data Types Operators Concept Learning Examples Operators Solved Practical Examples elational nary)