Sqlite Lab
Sqlite Lab
**Create Database:**
```sql
-- Instead, the database is created when you connect to a new database file.
```
**Create Tables:**
```sql
Mngr_no INTEGER,
);
);
```
### 2. Insert Records into Tables
```sql
INSERT INTO Employee (Emp_no, Emp_name, Age, Dept_code, Mngr_no, Salary) VALUES
```
```sql
```
```sql
```
```sql
FROM Employee
```
**Query 7: Display names of employees and their department name where they are working**
(Same as Query 6)
```sql
FROM Employee
```
```sql
```
**Query 9: Display details of employees whose salaries are within range of 18,000 to 38,000**
```sql
```
**Query 10: Display name, department_name and salary of managers in ascending order salary
wise**
```sql
FROM Employee
```
**Query 11: Name the employees who are earning more than the average salaries of employees**
```sql
```
**Query 12: Name the employees who are earning more than the salary of their manager**
```sql
```
These SQL commands will create the required tables, insert the specified records, and perform the
queries to meet the given tasks. Make sure to run these queries within a SQL environment
connected to the `WORK.db` database.
To accomplish the tasks you’ve outlined, follow these steps. I’ll use a hypothetical database name,
`SchoolDB`, but you can replace it with your preferred name.
First, create the database and table. Here's the SQL to create the database and the `Class` table:
```sql
USE SchoolDB;
);
```
```sql
```
To display the branch and total strength for a particular branch (e.g., BCA):
```sql
FROM Class
GROUP BY Branch;
```
```sql
FROM Class
GROUP BY Year;
```
### 5. Display Year and Strength for BCA in Ascending Order of Strength
```sql
SELECT Year, Total_student
FROM Class
```
### 6. Display Branch and Year Where Strength is More Than 110
To display the branch and year for those years where strength is more than 110:
```sql
FROM Class
```
### 7. Display Branch and Total Strength Where Total Strength is More Than 400
To display the branch and total strength where total strength is more than 400:
```sql
FROM Class
GROUP BY Branch
```
FROM Class
GROUP BY Branch;
```
### 9. Display Branch, Year, and Total Strength Where First Letter of Branch Starts with ‘B’
To display branch, year, and total strength for branches where the first letter is ‘B’:
```sql
FROM Class
```
### 10. Display Branch, Year, and Total Strength Where Second Letter of Branch Starts with ‘C’
To display branch, year, and total strength where the second letter is ‘C’:
```sql
FROM Class
```
Replace the placeholders and adjust the queries as needed based on your actual requirements.