SQL Record Questions Part1
SQL Record Questions Part1
Output (Write on the output side . For outputs you have to draw the table structure.
Format as shown below.)
pow(5,2)
25
1. select pow(5,2);
3. select sqrt(500);
1
5. select concat(day(now()),concat('-',month(now()), concat('-',year(now())))) as "Date";
6. select right("MEDIA",3);
9. select mod(346,3);
Program 2 : Queries Set 2 (Database- Fetching Records from the table Salesman):-
Consider the following table Salesman details and write queries to answer the following
questions.
Table name : salesman
Primary key: salesman_id
2
salesman_id | name | city | commission
-------------+------------+----------+------------
5001 | James Hoog | New York | 0.15
5002 | Nail Knite | Paris | 0.13
5005 | Pit Alex | London | 0.11
5006 | Mc Lyon | Paris | 0.14
5007 | Paul Adam | Rome | 0.13
5003 | Lauson Hen | San Jose | 0.12
5008 | Park Maax | Rome | 0.12
3
5. select salesman_id, name, city from salesman where commission=(select
max(commission) from salesman);
Suppose your school management has decided to conduct cricket matches between students of
Class XI and Class XII. Students of each class are asked to join any one of the four teams – Team
Titan, Team Rockers, Team Magnet and Team Hurricane. During summer vacations, various
matches will be conducted between these teams. Help your sports teacher to do the following:
4
Output (Write on the output side)
1. create database sports;
2. create table team (teamid int ,teamname varchar(10) not null, primary key(teamid));
a. Inserting data
insert into team values(1,'Tehlka');
insert into team values(2,'Toofan');
insert into team values(3,'Aandhi');
insert into team values(4,' Shailab ');
5
After inserting values
Program 4 : Queries Set 4 (Based on two tables in the above example team and
match_details):-
1. Display the matchid, teamid, teamscore who scored more than 70 in first inning along
with team name.
2. Display matchid, teamname and secondteamscore between 100 to 160.
3. Display matchid, teamnames along with matchdates.
4. Display unique team names
5. Display matchid and matchdate played by Anadhi and Shailab.
6
3. select matchid,teamname,firstteamid,secondteamid,matchdate from match_details, team
where match_details.firstteamid=team.teamid;
7
1. Display all the items in the ascending order of stockdate.
2. Display maximum price of items for each dealer individually as per dcode from stock.
3. Display all the items in descending orders of item names.
4. Display average price of items for each dealer individually as per dcode from stock which
average price is more than 5.
5. Display the sum of quantity for each dcode.
8
5. select dcode, sum(qty) from stock group by dcode;
Ashalakshmi.R
(05.11.2023)