0% found this document useful (0 votes)
5 views

Basic SQL Queries

Uploaded by

skumar45753
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)
5 views

Basic SQL Queries

Uploaded by

skumar45753
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/ 2

Basic SQL Queries

-- Create a Table

CREATE TABLE Employees (

EmployeeID INT PRIMARY KEY,

FirstName VARCHAR(50),

LastName VARCHAR(50),

Department VARCHAR(50),

Salary DECIMAL(10, 2)

);

-- Insert Data

INSERT INTO Employees (EmployeeID, FirstName, LastName, Department, Salary)

VALUES

(1, 'John', 'Doe', 'HR', 50000.00),

(2, 'Jane', 'Smith', 'IT', 75000.00),

(3, 'Robert', 'Brown', 'Finance', 60000.00);

-- Query 1: Select all employees

SELECT * FROM Employees;

-- Query 2: Find employees with salary greater than 60000

SELECT * FROM Employees WHERE Salary > 60000;

-- Query 3: Update salary of a specific employee

UPDATE Employees SET Salary = 80000 WHERE EmployeeID = 2;


-- Query 4: Delete an employee from the table

DELETE FROM Employees WHERE EmployeeID = 1;

-- Query 5: Count employees in each department

SELECT Department, COUNT(*) AS EmployeeCount

FROM Employees

GROUP BY Department;

You might also like