A company maintains records of sales made by its salespersons and pays them commission based on each individual’s total sales made in a year. This data is maintained in a table with following schema:
salesinfo = (salespersonid, totalsales, commission)In a certain year, due to better business results, the company decides to further reward its salespersons by enhancing the commission paid to them as per the following formula:
If commission < = 50000, enhance it by 2%
If 50000 < commission < = 100000, enhance it by 4%
If commission > 100000, enhance it by 6%
The IT staff has written three different SQL scripts to calculate enhancement for each slab, each of these scripts is to run as a separate transaction as follows:
T1: Update salesinfo
Set commission = commission * 1.02
Where commission < = 50000;
T2: Update salesinfo
Set commission = commission * 1.04
Where commission > 50000 and commission is < = 100000;
T3: Update salesinfo
Set commission = commission * 1.06
Where commission > 100000;
Which of the following options of running these transactions will update the commission of all salespersons correctly?The employee information in a company is stored in the relation
Employee (name, sex, salary, deptName)Consider the following SQL query
Select deptName
From Employee
Where sex = ‘M’
Group by deptName
Having avg(salary) >
(Select avg (salary) From Employee);
It returns the names of the department in whichTable: Student
| Roll_no | Name | Dept_id |
|---|---|---|
| 1 | ABC | 1 |
| 2 | DEF | 1 |
| 3 | GHI | 2 |
| 4 | JKL | 3 |
Table: Department
| Dept_id | Dept_name |
|---|---|
| 1 | A |
| 2 | B |
| 3 | C |
Roll_no is the primary key of the Student table, Dept_id is the primary key of the
Department table and Studetn.Dept_id is a foreign key from
Department. Dept_id.
(i) update Student set Dept_id = Null where Roll_no =1
(ii) update Department set Dept_id = Null where Dept_id =1 Insert into department values (1, ‘Mathematics’)
Insert into department values (2, ‘Physics’)
Insert into student values (1, ‘Navin’,1)
Insert into student values (2, ‘Mukesh’,2)
Insert into student values (3, ‘Gita’,1)
How many rows and columns will be retrieved by the following SQL statement?
Select * from student, department;GATE CSE Subjects
Browse all chapters by subject