Wa0011
Wa0011
Wa0011
no18
SQL Table-1
Aim: To create a table for students and execute the given commands using
SQL.
SQL Queries:
A) To create a table Student with fields Studentid ,Studentname ,M1,M2,M3
and Set Studentid as a Primary key
create table Student(Studentid int primary key,
studentname varchar(10), M1 int, M2 int, M3 int);
B )To describe command is used to display the data definition, data types with
default values
Describe student;
E) To display the details of the student whose marks are greater than equal to 50
Select * from student where m1>=50 and m2>=50 and m3>=50;
ex.no19
SQL table -2
Aim: To create a table Consumer and execute the queries.
A) To create a table Consumer with fields Consumerid , Consumer name
,Gender,Pincode and Set Consumerid as a Primary key
create table consumer(consumerid int primary key,consumername
varchar(30),Gender char(1), pincode int);
B) Insert values into table
insert into Consumer values(1200,'Grace','F',100012);
insert into Consumer values(1201,'Nick','M',610012);
insert into Consumer values(1204,'Berry','M',420012);
insert into Consumer values(1207,'wood','M',210011);
insert into Consumer values(1209,'Helen','F',410011);
insert into Consumer values(1210,'Jennifer','F',510011);
insert into Consumer values(1211,'Jennifer','F',510011);
D)To display the consumer name from Table consumer with redundancy
select all consumername from consumer;
A) To display the details of employee whose dept is IT and the salary is greater
than or equal to 10000
select * from employee where dept='IT' and salary>=10000;
B) Display the Employee name in the Alphabetical order
select * from employee order by empname;
C) Display salary from greater to smaller.
select * from employee order by salary desc;
D) Display the column name empname as Employee name
select empname as Employeename from employee;
E) To increase salary of the Employee by 1000 where department name is
Shipping
select empid,empname,salary+1000 from employee where dept='Shipping';
F) Enter a NULL value in the Department name of the Employee Table
insert into employee values(3111,'George','NULL',9000)
ex.no 21
SQL TABLE-4
Aim: To Execute the Aggregate functions using the Employee table
SQL Queries:
select * from employee;
h) To display the department wise count whose count is greater than 3 in each
group
select dept,count(*) from employee group by dept having count(*)<3;
ex.no22
SQL TABLE-5
AIM
To create table Stationary ,Stock,Sto and execute the commands.
1)create table stationary(Item_no int primary key,
-> Item varchar(20), Dcode int,Qty int, Unitprice int,StockDate Date);
a)To add a foreign key in the table Stationary the parent table is Stock
alter table stationary add foreign key (dcode) references stock(scode);
b) To create a Cartesian product of the table Stationary and Stock
Select * from stationary, stock;
c) To display the details of the Stationary and Stock using EQUI join
Select * from stationary, stock where stationary.dcode=stock.scode;
d) To display the details of the Stock and Sto using Natural join
select * from stock natural join sto;