SQL Assignments
Provides Latest and Useful Assignments on SQL technology
Provides Latest and Useful Assignments on SQL technology
1.create database name mydb.
2.write a query to create table having id,name,gender,city and salary columns, under mydb database.
3.rename database mydb to mydatabase.
4.write a query to create table employee having id,name,gender,city and salary columns, under mydatabase database.
5.write a query to select particular column of table.
6.write a query to view all records of table.
7.write a query to add new column of table.
8.write a query to create table of employee having id,name,gender,city and salary.
9.write a query to print details of employee whose first name starts with 'a'.
10.write a query to print details of employee whose city starts with 'n'.
11.write a query to print details of employee whose first name ends with 'r'.
12.write a query to display maximum salary of employee
13.write a query to display minimum salary of employee
14.write a query to display total salary of employee
15.write a query to display average of salary of employee
16.write a query to add new column in employee table
17.write a query to update multiple fields of employee table
18.write a query to drop a column from employee table
1.create a student table having id,name,gender,city,mobile and roll number.Insert 5 rows in student table.
2.write a query to display unique student name using distinct function.
3. write a query to add new column address in student table.
4.write a query to change data type of roll number column to bigint.
5. write a query to display particular records of student table.
6. write a query to drop address column.
7.write a query to update multiple fields of student table.
8. write a query to truncate student table.
9. write a query to drop student table.
10.write a query to drop current database.
1.write a query to print unique city of all employee
2.write a query to print sum of total salary of all employee.
3.write a query to print total rows of employee table.
4.write a query to count total employees of employee table.
5.write a query to print average of employee salary.
6.write a query to print record of all employees whose date of birth between 1991 to 2005
7.write a query to print record of employees whose city in either noida or kanpur.
8.write a query to print record of employees whose city in kanpur,delhi and noida
9.write a query to print record of employees whose first name start with 'm'.
10.write a query to print top 3 employees.
11.write a query to print record of employee and their name in ascending order.
1.write a query to print average of salary of employee whose name starts with 'm'
2.write a query to print average of salary of employee whose name ends with 'n'
3.write a query to print sum of salary of employee whose city in noida,delhi and punjab
4.write a query to print sum of salary of employee whose city not in faridabad,punjab and delhi
5. write a query to apply primary key on table column
6.write a query to apply unique key on table column
7.write a query to do not allow null value on specific column
8.write a query to allow number in column if it is positive number
9.write a SQL statement that display all the information about all salesperson having salesman_id,name,city and commission.
10.write a SQL query to display sum of max and min of employee salary
11.write a SQL query to display average of max and min of employee salary
12.write a sql query to display cities of employees whose salary is greater than 20000
13.write a sql query to display gender of employee whose salary is less than 50000
1.create two tables department and employee, in department table add four records having id-1,2,4 & 5 and in employee table add six records having id-1,2,3,4,5 and 6.
2.perform inner join on department and employee tables.
3.perform left join on department and employee tables.
4.perform right join on department and employee tables.
5.perform full outer join on department and employee tables.
6.write a sql statement that displays all the information about all salesperson.
7.write a sql query to display the sum of two number 10 and 15 from RDBMS server.
8.write a sql query to display the result of an arithmetic operation.
9.write a sql statement to display the specific column such as name and commission for all the salesperson.
10.write a sql query to display the column in a specific order, such as order date, and purchase amount for all the orders.
1.write a query to print even and odd using scalar function in sql.
2.write a query to print positive or negative number using scalar function in sql.
3. write a query to print square of any number using scalar function in sql.
4. write a query to print cube of any number using scalar function in sql.
5. write a query to print sum of three integer using scalar function in sql.
6.write a query to print sum of three integer using scalar function in sql.
7. write a query to print your name using scalar function in sql.
8.write a query to print total employees gender wise. HINT: use stored procedure having (input and output parameter).
9. write a query to print total student city wise. HINT: use stored procedure having(input and output parameter)
10.write a query to perform inner join inside stored procedure and print it.
1write a query to return total sum of employee salary using scalar function.
2write a query to return average salary of employee using scalar function.
3write a query to return records of employee whose name start with 'a' using inline table valued function.
4write a query to return records of employee whose salary greater than 10000 using inline table valued function.
5write a query to perform union and union all in sql.
6write a query to perform intersect and except in sql.
7write a query to print total salary of employee city wise.
8write a query to print average salary of employee gender wise.
9write a query to print average salary of employee city wise.
1.find 6th hignest salary of employee.
2.find 3rd highest salary of employee.
3. create procedure that print any highest salary.
4.create procedure that print sum of second highest salary and fourth highest salary.
5.create procedure to return difference of sum of salary and max of salary using output parameter.
6.print inner join using stored procedure on window form.
7.print difference of second highest and fourth highest salary of employee using stored procedure.
8.create trigger on employee table that gets fired and print some message on insertion of any record in employee table
9.create trigger on student table that gets fired and print message on deletion of any record from employee table.
10.create trigger on employee table that print deleted record from employee table.
1.create clustered index on customer(id) table.
2.create non clustered index on person(id) and person(name) table
3.create unique index on employee(id) table.
4.write a query to drop index
5.write a query to view all indexes of current table.
6.use rollback transaction to delete record of student.
7.use commit transaction to delete record of student.
8.try to see uncommited transaction in other connection.
9.use try and catch block for divide by zero exception in sql.
10.execute transaction for update query under stored procedure.
1.waq to return table using table valued function.
2.waq to return average of employee salary using inline table valued function.
3.waq to return product of employee salary using inline table valued function.
4.write short notes on function in sql.
5. write short notes on trigger in sql.
6.do practice on aggregate function.
7.create a function that takes a number as an argument, increments the number by +1 and returns the result.
8.Create a function that takes age in years and returns the age in days.
9.Create a function that takes voltage and current and returns the calculated power.
10.create a local temporary table name person having id,name,gender, city and salary.
1.create a local temporary table name student having id,name,gender, city and salary.
2.create a global temporary table name customer having id,name,amout, city
3.create a local temporary table name student having id,name,gender, city and salary.
4.Create a trigger inside procedure for insert operation on sql table . When trigger gets fired message should be displayed.
5.Create a trigger inside procedure for delete opertaion on sql table. when trigger gets fired message should be displayed.
6.create cursor to fetch first record of student table without variable.
7.ccreate cursor to fetch last record of student table without variable.
8.create cursor to fetch second last record od student table without variable.
9.create cursor to fetch id and name of first record using variable.
10.return total salary of employees of a table inside procedure.
11.return total salary of employees citywise inside procedure.