Select chapter



Basics (2.papers)
Data Types (2.papers)
Table-designing (1.papers)
Queries-Commands (3.papers)
String functions (2.papers)
Subqueries (1.papers)
Joins (1.papers)
Constraints (1.papers)
Triggers (1.papers)
Hide

Sponsored Links


  

sql aggregate functions interview questions and answers

Please read the below given table for solving questions from 1 to 18
eidfnamelnameagesalarydeptdoj
1rajeevsukla2312000.net23-Oct-11 12:00:00 AM
2sowmyakumari2319000db13-Nov-10 12:00:00 AM
3kishorekumar2736000android16-Oct-11 12:00:00 AM
4abimanyubiswal22nullandroid25-May-10 12:00:00 AM
5sonikumar2421800.net21-Jun-09 12:00:00 AM
6anu_singh2212000db23-Oct-10 12:00:00 AM
7_dineshmoh%anty2315000.net26-Aug-09 12:00:00 AM
8nischala_kumari2218000db19-Jul-08 12:00:00 AM
9gouravchourasia2420000android06-Oct-13 12:00:00 AM
Note: Assume table is present in a database named skillgun , the Schema name is dbo and the table name as Employees ;
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
3
Which of the following queries can be used for calculating average salary of all the employees?
  1. select avg(salary) from employees ;
  2. select avg(salary) as 'avgsal' from employees ;
  3. select avg(salary) 'avgsal' from employees ;
  4. All the options are correct.
Show Answer
Share Facebook gmail Twitter
4
Which of the following queries will return average salary of all the .net dept employees?
  1. select avg(salary) from employees ;
  2. select avg(salary) as '.netdeptsal' from employees ;
  3. select avg(salary) 'avgsal' from employees where dept='.net';
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
5
Which of the following queries will return average salaries of all employees, whose lnames are starting character k?
  1. select avg(salary) from employees where lname='K%';
  2. select avg(salary) from employees where salary like '%k%' ;
  3. select avg(salary) as 'avgsal' from employees where lname like '%k';
  4. select avg(salary) as 'avgsal' from employees where lname like 'k%';
Show Answer
Share Facebook gmail Twitter
6
Which of the following queries will display the employees fullnames whose salary is more than android department employees average salary?
  1. select fname+lname as 'fullname' from employees where salary>avg(salary) and dept='android' ;
  2. /*declaring variable in sql */
    declare @and_dept_avgsal int;
    select @and_dept_avgsal=AVG(salary) from employees where dept='android';
    select fname+lname as 'fullname' from employees where salary>@and_dept_avgsal;
  3. select fname+lname as fullname where salary>avg(select salary from employees where dept='android')
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
7
Which of the following queries will display all android dept employees fullnames whose salaries are greater than the corresponding department average salary?
  1. select fname+lname as 'fullname' from employees where salary>avg(salary) and dept='android' ;
  2. /*declaring variable in sql */
    declare @and_dept_avgsal int;
    select @and_dept_avgsal=AVG(salary) from employees where dept='android';
    select fname+lname as 'fullname' from employees where salary>@and_dept_avgsal;
  3. declare @and_dept_avgsal int;
    select @and_dept_avgsal=AVG(salary) from employees where dept='android';
    select fname+lname as 'fullname' from employees where salary>@and_dept_avgsal and dept='android';
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
8
Which of the following queries will display total salaries of all the employees?
  1. select total(salary) from employees ;
  2. select sum of salary from employees ;
  3. select sum(salary) from employees ;
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
9
Which of the following queries will display total salaries of all db department employees?
  1. select sum(salary) from employees where dept='db' ;
  2. select sum(salary) from employees ;
  3. select sum(salary) from employees where dept like 'db' ;
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
10
Which of the following queries will display the minimum salary in employees table?
  1. select min(salary) as minsal from employees ;
  2. select minimum(salary) from employees ;
  3. select least(salary) from employees ;
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
11
Which of the following queries is used for displaying least paid employees fname?
  1. select fname from employees where salary=min(salary) ;
  2. select fname,min(salary) from employees ;
  3. declare @min_sal int;
    select @min_sal=MIN(salary) from employees ;
    select fname from employees where salary=@min_sal ;
  4. None of the above
Show Answer
Share Facebook gmail Twitter
12
Which of the following queries will display top or maximum salary?
  1. select top(salary) from employees ;
  2. select max(salary) from employees ;
  3. select maximum(salary) from employees ;
  4. None of the above
Show Answer
Share Facebook gmail Twitter
13
Which of the following queries is used for displaying fnames of highest paid employees?
  1. select fname from employees where salary=max(salary) ;
  2. select fname from employees where salary=highest(salary) ;
  3. declare @min_sal int;
    select @min_sal=top(salary) from employees ;
    select fname from employees where salary=@min_sal ;
  4. declare @min_sal int;
    select @min_sal=Max(salary) from employees ;
    select fname from employees where salary=@min_sal ;
Show Answer
Share Facebook gmail Twitter
14
What is the use of count function in SQL?
  1. count function used only for displaying total number of columns present in the original table.
  2. count function used for displaying total number of rows present in the result set.
  3. count function used for displaying total number of columns present in the result set.
  4. None of the above
Show Answer
Share Facebook gmail Twitter
15
Which of the following queries is used for displaying total number of employees whose fnames are having character "a" any where in their fnames?
  1. select count(*) from employees where fname='a%' ;
  2. select count(*) from employees where fname like '%a%' ;
  3. select count from employees where fname like '%a%' ;
  4. None of the above
Show Answer
Share Facebook gmail Twitter
16
What is the output for the following query?
Query:
select count(fname) from employees where dept<>'.net'
  1. Query will produce parser error since * is the only entity allowed inside count function.
  2. 6
  3. 3
  4. Query will produce error since we must use 
    column name which is used in where clause inside count function.
Show Answer
Share Facebook gmail Twitter
17
What is the output for the following query?
Query:
select count(fname),fname from employees ;
  1. Query will produce parser error since select list must contain only aggregate function of the column names which are used in group by or having clauses.
  2. Query will return 6 and all employees fnames.
  3. Query will return only count functions output.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
18
What is the output for the following query?
Query:
select count(fname),min(salary),sum(salary),max(salary) from employees 
  1. Query will produce parser error showing reason as multiple aggregate functions are not allowed in a single select list.
  2. 10
  3. 10,12000,165800,36000
  4. None of the above
Show Answer
Share Facebook gmail Twitter
Read more papers :