Skip to toolbar

Forum

What are the common...
 
Notifications
Clear all

What are the commonly used SQL Queries on Employee Table?  


Ganeshan Kumaran
Posts: 36
 Ganeshan Kumaran
Guest
(@Ganeshan Kumaran)
Joined: 2 months ago

Hello,

What are the commonly used SQL Queries using Employee Table?

Will be more helpful if you can give some examples with data.

1 Reply
VK
Posts: 9
 VK
Guest
(@VK)
Joined: 2 months ago

I will use the below employee table to write some queries and show the expected results so that you will be able to understand very well. 

Below is my Employee table. 

Emp ID

First_Name

Salary

Department

1

Anandh

5000

AAA

2

Anjali

7000

BBB

3

Arun

8500

ABC

4

Deepak

15000

AAA

5

John

22000

CDN

6

Monalisa

28000

KSN

7

Sandhya

32000

AAA

8

Rohan

40000

NND

 

Query:

1) How to Increase the income of all employees by 5% in a table? 

 SQL: Update Employee SET Income=Income+(Income*5.0/100)

 Expected Results:

Emp ID

First_Name

Salary

Department

1

Anandh

5250

AAA

2

Anjali

7350

BBB

3

Arun

8925

ABC

4

Deepak

15750

AAA

5

John

23100

CDN

6

Monalisa

29400

KSN

7

Sandhya

33600

AAA

8

Rohan

42000

NND

 

Query

2) Find the name of an employee starting with 'A'?

SQL: Select first_name From Employees where first_name Like 'A%'

Expected Results: 

 

Emp ID

First_Name

Salary

Department

1

Anandh

5000

AAA

2

Anjali

7000

BBB

3

Arun

8500

ABC

 

Query:

3) Find the number of employees working in the department 'ABC'

 

SQL: Select Count(*) from employees where department_name='ABC'

Expected Results:

Emp ID

First_Name

Salary

Department

1

Arun

8500

ABC

 

Query

4) Print Details of employees whose first name ends with 'A' and contains 5 Alphabets

 

SQL: Select * from Employees where First_Name Like '_ _ _ _ a'

Expected Results:

 

Emp ID

First_Name

Salary

Department

1

Monalisa

28000

KSN

2

Sandhya

32000

AAA

 

Query

5) Print details of an employee whose salary lies between 5000 and 25000

SQL: Select * from Employee Where Salary BETWEEN 5000 and 25000

Expected Results:

 

Emp ID

First_Name

Salary

Department

1

Anandh

5000

AAA

2

Anjali

7000

BBB

3

Arun

8500

ABC

4

Deepak

15000

AAA

5

John

22000

CDN

 

Reply

Leave a reply

Author Name

Author Email

Title *

Maximum allowed file size is 10MB

 
Preview 0 Revisions Saved
Share: