Learn SQL Server with Example
FIRST WE CREATE TABLE
create table EMP
(
ENAME varchar(50) null,
DEPT_NAME varchar(50) null,
DESTINATION varchar(50) null,
SALARY varchar(50) null,
DATE_OF_JOIN date null DEFAULT GETDATE()
)
NOW NEED TO INSERT DATA
insert into EMP(ENAME,DEPT_NAME,DESTINATION,SALARY,DATE_OF_JOIN)
values('JHOHN','SALES','SALESMAN',20000,'2020-02-20'),
('LEZZY','SALES','SALESMAN',23000,'2023-05-05'),
('KAMAAL','ACCOUNT','CLERK',34000,'2019-07-04'),
('RITESH','ACCOUNT','MANAGER',40000,'2015-08-15'),
('SAXENA','SALES','SALESMAN',21000,'2015-10-10'),
('MANI','ACCOUNT','CLERK',34000,'2015-07-04')
After create and insert let's view data using diffrent -2 operators and logic.
If you want to show your all column and inside data you have to simply use select query with astrick(*) with from and table name , and then execute quiery using execute button or press "CTRL + F5".
for example
SELECT *FROM EMP
There are some questions set of querys:-
1) Query for find all the ENAME whose salary is less than "25000"?
select *from EMP where SALARY < 25000
4) Query for find total no of employees whose work Account department?
select *from EMP where DEPT_NAME='account'
6) Query for sort EMP table by 'ENAME'?
select *from EMP order by ENAME
with order by you can use asc for accending order and desc for descending order, SQL use by default accesnding order.
Comments
Post a Comment