Q. Consider the table RESULT given below. Write commands in MySQL for (a) to (d) and output for (e) to (g):


Table: RESULT


 
No Name Stipend Subject Average Division
1 Sharon 400 English 38 THIRD
2 Amal 680 Mathematics 72 FIRST
3 Vedant 500 Accounts 67 FIRST
4 Shakeer 200 Informatics 55 SECOND
5 Anandha 400 History 85 FIRST
6 Upasna 550 Geography 45 THIRD

(a) To list the names of those students who have obtained Division as FIRST in the ascending order of NAME.

(b) To display a report listing NAME, SUBJECT and Annual stipend received assuming that stipend the column has monthly stipend.

(c) To count the number of students who have either Accounts or Informatics as subject.

(d) To insert a new row in the table EXAM: 6, "Mohan", 500, "English", 73, "Second"

(e) select avg(Stipend) from EXAM where DIVISION = "THIRD";

(f) select count(distinct Subject) from EXAM;

(g) select min(Average) from EXAM where Subject = "English";


Answer :-

(a) Select name from RESULT where Division = “FIRST” ;
(b) Select NAME, SUBJECT , (Stipend * 12 ) as “Annual stipend” from RESULT ;
(c) Select Count(*) from Result where Subject = “Accounts” or subject = “Information” ;
# Lets Assume Exam Table = Result Table
(d) Insert into Result values ( 6, "Mohan", 500, "English", 73, "Second" ) ;
(e)

 
avg(Stipend)
41.5

(f)

 
count(distinct Subject)
6

(g)

 
min(Average)
38

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post