0% found this document useful (0 votes)
12 views

Practise SQL Questions

The document provides SQL questions and queries related to creating tables, inserting, updating, deleting and retrieving data from tables. It includes questions to: 1. Create a "publisher" table with columns for publisher details 2. Write queries to display publisher details by country, name and branches in certain countries, and other criteria 3. Write queries on "TRAINER" and "COURSE" tables to display names, salaries, fees and other details based on given conditions.

Uploaded by

Ojaswi Om
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Practise SQL Questions

The document provides SQL questions and queries related to creating tables, inserting, updating, deleting and retrieving data from tables. It includes questions to: 1. Create a "publisher" table with columns for publisher details 2. Write queries to display publisher details by country, name and branches in certain countries, and other criteria 3. Write queries on "TRAINER" and "COURSE" tables to display names, salaries, fees and other details based on given conditions.

Uploaded by

Ojaswi Om
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PRACTISE SQL QUESTIONS

1.Give MySQL commands for the following –


a.Create a table called “publisher” according to the information given below–

Column Name Datatype Size Remark


pub_id varchar 8 Publisher id
pub_name varchar 50 Publisher name
pub_city varchar 25 Publisher city
country varchar 25 Country
country_office varchar 25 Name of city of head office
no_of_branch int 3 No of branches in the country
estd date Establishment date

b.Display the details of all publisher arranged according to country in


ascending manner.
c.Display the publisher name and no of branches who have country offices in
“India” or “Sri Lanka”.
d.Display the name of the cities and no of branches of “Penguin Random
House” in “India”.
e.Display the publishing city and country of all the publications that were
established in the year 2002.
f.Display the details of all the publishers whose publication city has ‘e’ as the
3rd character.
g.Change the country office to “Mumbai” for “Harper Collins”.
h.Increase the no of branches to 7 for “Cambridge University Press” in
“Texas”.
i.Add a column “email” of type varchar size 40 which shouldnot be NULL.
j.Remove the details of all publishers whose establishment date is before 1942.
k.Finally remove the whole table.
2.Write SQL queries for the following –
Table – TRAINER
TID TNAME CITY HIREDATE SALARY
101 SURAJ MUMBAI 1994-10-15 90000
102 ANAMIKA DELHI 1998-12-24 80000
103 DEEPTI CHANDIGARH 2001-12-21 82000
104 MEENAKSHI DELHI 2002-12-25 78000
105 CHETAN MUMBAI 1996-01-12 85000
106 PRABHAT CHENNAI 2002-12-12 69000

Table – COURSE
CID CNAME FEES STARTDATE TID
C201 AGDCA 12000 2019-07-02 101
C202 ADCA 15000 2019-07-15 103
C203 DCA 10000 2020-01-13 102
C204 DDTP 2019-09-15 104

C205 DHN 20000 2020-01-13 101


C206 O LEVEL 18000 2019-07-25 105

i.Display the trainer and course names of all the courses that began in the
year 2020.
ii.Display the name and fee of the course(s) being taught by ‘Deepti’.
iii.Display the name and salary of the trainers who are taking the ‘O Level’
course.
iv.Display the trainer name, course name and fee of all the courses available
in ‘Mumbai or ‘Delhi’ and fee column should not be empty
v.Display trainer name, hire date, course name and course start date of all
those courses whose fees is more than or equal to 10000 but less than or
equal to1800.
vi.Print maximum salary of trainers for each city only if no. of trainers is more than 2
in the cities.
vii.Add primary key constraint to TID of trainer.
viii.Remove the column city.
ix.Insert a row in trainer with following values:
tid=107,tname=megha,city=ranchi,hiredate=2005-11-24

You might also like