0% found this document useful (0 votes)
7 views6 pages

Detailed SQL Practical Programs

The document provides a series of SQL commands for retrieving data from an Employee table. It includes commands to display all records, filter salaries above 20000, find the employee with the highest salary, select employees with names starting with 'P', and calculate the total salary of all employees. Each command is accompanied by an explanation and sample output.

Uploaded by

arena360yt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Detailed SQL Practical Programs

The document provides a series of SQL commands for retrieving data from an Employee table. It includes commands to display all records, filter salaries above 20000, find the employee with the highest salary, select employees with names starting with 'P', and calculate the total salary of all employees. Each command is accompanied by an explanation and sample output.

Uploaded by

arena360yt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Detailed SQL Practical Section

Question: Write an SQL command to show all the records of the table.

Explanation:

This command retrieves all rows and columns from the Employee table, displaying the complete

data stored in it.

SQL Command:

SELECT * FROM Employee;

Sample Output:

| Empno | Employee Name | Salary |

|-------|---------------|---------|

|1 | Jack | 21000 |

|2 | Robin | 25000 |

|3 | Mary | 17500 |

|4 | Pradeep | 16000 |

|5 | Priya | 22700 |
Question: Write an SQL command to show the salaries more than 20000.

Explanation:

This command retrieves rows from the Employee table where the salary column has values greater

than 20000.

SQL Command:

SELECT * FROM Employee WHERE Salary > 20000;

Sample Output:

| Empno | Employee Name | Salary |

|-------|---------------|---------|

|2 | Robin | 25000 |

|5 | Priya | 22700 |
Question: Write an SQL command to show the employee with the highest

salary.

Explanation:

This command retrieves the record of the employee who has the maximum salary in the Employee

table.

SQL Command:

SELECT * FROM Employee ORDER BY Salary DESC LIMIT 1;

Sample Output:

| Empno | Employee Name | Salary |

|-------|---------------|---------|

|2 | Robin | 25000 |
Question: Write an SQL command to show the records of employees whose

names start with 'P'.

Explanation:

This command retrieves all rows from the Employee table where the Employee Name starts with the

letter 'P'.

SQL Command:

SELECT * FROM Employee WHERE Employee_Name LIKE 'P%';

Sample Output:

| Empno | Employee Name | Salary |

|-------|---------------|---------|

|4 | Pradeep | 16000 |

|5 | Priya | 22700 |
Question: Write an SQL command to show the total salary of all employees.

Explanation:

This command calculates the total salary of all employees in the Employee table using the SUM()

function.

SQL Command:

SELECT SUM(Salary) AS Total_Salary FROM Employee;

Sample Output:

| Total_Salary |

|--------------|

| 102200 |

You might also like