PRACTISE SQL QUESTIONS
[Link] MySQL commands for the following –
[Link] 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
[Link] the details of all publisher arranged according to country in
ascending manner.
[Link] the publisher name and no of branches who have country offices in
“India” or “Sri Lanka”.
[Link] the name of the cities and no of branches of “Penguin Random
House” in “India”.
[Link] the publishing city and country of all the publications that were
established in the year 2002.
[Link] the details of all the publishers whose publication city has ‘e’ as the
3rd character.
[Link] the country office to “Mumbai” for “Harper Collins”.
[Link] the no of branches to 7 for “Cambridge University Press” in
“Texas”.
[Link] a column “email” of type varchar size 40 which shouldnot be NULL.
[Link] the details of all publishers whose establishment date is before 1942.
[Link] remove the whole table.
[Link] 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
[Link] the trainer and course names of all the courses that began in the
year 2020.
[Link] the name and fee of the course(s) being taught by ‘Deepti’.
[Link] the name and salary of the trainers who are taking the ‘O Level’
course.
[Link] the trainer name, course name and fee of all the courses available
in ‘Mumbai or ‘Delhi’ and fee column should not be empty
[Link] 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.
[Link] maximum salary of trainers for each city only if no. of trainers is more than 2
in the cities.
[Link] primary key constraint to TID of trainer.
[Link] the column city.
[Link] a row in trainer with following values:
tid=107,tname=megha,city=ranchi,hiredate=2005-11-24