1.

Consider the table given below :Write Answer to (i). Write SQL queries for (ii) to (viii) and output for SQL queries (ix) and (x).(Table : Salesperson)SIDNamePhoneDOBSalaryAreaS101Amit Kumar987017896541967-01-2367000.00NorthS102Deepika Sharma991045678341992-09-2332000.00SouthS103Vinay Srivastav981015467891991-06-2735000.00NorthS104Kumar Mehta886753457891967-10-1640000.00EastS105Rashmi Kumar981015674341972-09-2050000.00SouthNote: Columns SID and DOB contain Sales Person Id and Data of Birth respectively.(i) Write the data types of SID and DOB columns.(ii) Display names of Salespersons and their Salaries who have salaries in the range 30000.00 to 40000.00.(iii) To list Names, Phone numbers and DOB (Date of Birth) of Salespersons who were born before 1st November 1992.(iv) To display Names and salaries of salespersons in descending order of salary.(v) To displays areas in which Salespersons are working. Duplicate Areas should not be displayed. (vi) To display SID, Names along with Salaries increased by 500. (Increase of t 500 is only to be displayed and not to be updated in the table).(vii) To display Area along with number of Salespersons working in that area.(viii) To display Names of Salespersons who have the word 'Kumar' anywhere in their names.(ix) SELECT Name, LENGTH (Name) FROM Salesperson;(x) SELECT Area, COUNT (*)FROM SalespersonGROUP BY AreaHAVING COUNT (*) > 1;

Answer»

(i) SID=varchar().

DOB = date.

(ii) SELECT Name FROM Salesperson WHERE Salary BETWEEN 30000.00 AND 40000.00;

(iii) SELECT Name, Phone, DOB FROM Salesperson WHERE DOB< '1 - 11 - 1992' ;

(iv) SELECT Name, Salary FROM Salesperson ORDER BY Salary DESC;

(v) SELECT DISTINCT(Area) FROM Salesperson;

(vi) SELECT SlD,Name,Salary+500 FROM Salesperson;

(vii) SELECT Area, Phone FROM Salesperson;

(viii) SELECT Name FROM Salesperson WHERE Name LIKE "%Kumar%";

(ix)   Amit Kumar                   10

        Deepika Sharma           14

        Vinay Shrivastav           16

        Kumar Mehta                11

       Rashmi Kumar               12 

(x) North      2

    South      2



Discussion

No Comment Found

Related InterviewSolutions