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

Sumit Sadhu Dte 2 (SQL)

The document outlines SQL commands for creating and manipulating databases related to e-commerce sales, user data, and employee information. It includes the creation of tables, insertion of data, updates, and various SQL queries for data retrieval and analysis. The document serves as a practical guide for using SQL in business data mining applications.

Uploaded by

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

Sumit Sadhu Dte 2 (SQL)

The document outlines SQL commands for creating and manipulating databases related to e-commerce sales, user data, and employee information. It includes the creation of tables, insertion of data, updates, and various SQL queries for data retrieval and analysis. The document serves as a practical guide for using SQL in business data mining applications.

Uploaded by

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

Name: SUMIT SADHU

Reg. No.: 2023PGDM1357


Section: D
Course name: Business data Mining with SQL
2nd DTE

SECTION-A
1) create database EcommerceSales;
use EcommerceSales;

CREATE TABLE Orders


( OrderID INT PRIMARY KEY,
BuyerName VARCHAR(255),
ProductName VARCHAR (255),
Quantity INT,
Price DECIMAL(10,2),
OrderDate DATE,
Status VARCHAR(50)
);

ALTER TABLE Orders ADD PaymentMethod


VARCHAR(50);

INSERT INTO Orders (OrderID, BuyerName, ProductName,


Quantity, Price, OrderDate, Status, PaymentMethod)
VALUES (1, 'John Doe', 'Laptop', 1, 750.00, '2025-02-24',
'Pending', 'Creditcard'),
(2, 'Alice Smith', 'Headphones', 2, 50.00, '2025-02-23',
'Shipped', 'Paypal'),
(3, 'Michael Brown', 'SmartPhone', 1, 699.99, '2025-02-22',
'Pending', 'Debitcard'),
(4, 'Emma Wilson', 'Tablet', 3, 300.00, '2025-02-21', 'Pending',
'UPI'),
(5, 'David Johnson', 'Monitor', 1, 200.00, '2025-02-20',
'Processing', 'NetBanking');
UPDATE Orders SET Status = 'Shipped' WHERE OrderID = 3;

OUTPUT

SECTION-B
2) create database SAMPLE_DATABASE;
use SAMPLE_DATABASE;
create table USERS(
OrderID int primary key auto_increment,
Name_ varchar(100) not null,
age int not null,
city varchar(50) not null
);
insert into users values
(1,"alice", "25", "new york"),
(2,"bob", "30", "los angeles"),
(3,"charlie", "28", "chicago"),
(4,"david", 22, "san francisco"),
(5,"eve", "35", "seattle");

select name_, age from users where age > 25;


select name_, age from users order by age desc;

select name_, age,


case
when age > 30 then "senior"
when age = 30 then "senior"
when age < 30 then "junior"
else "default"
END as message
from users;
SELECT * FROM users WHERE age BETWEEN 25 AND 30 AND
city = 'Chicago';
SELECT * FROM users WHERE age NOT BETWEEN 25 AND 30;
OUTPUT

SECTION-C (CASE-STUDY)
5) use company_db;

create table employees(


id INT auto_increment primary key,
name VARCHAR(50),
department VARCHAR(50),
salary int null,
experience int,
performance BOOLEAN);
Insert into employees Values
(1, 'Alice', 'IT', 60000, 5, 1),
(2, 'Bob', 'HR', 45000, 3, 0),
(3, 'Charlie', 'Sales', null, 4, 1),
(4, 'David', 'IT', 7000, 6, 1),
(5, 'Emma', 'HR', 40000, 2, 0),
(6, 'Frank', 'Sales', 55000, 5, 1);

select*from employees;

select count(*) from employees group by department;

select department,avg(salary) from employees group by department


having sum(salary)>50000;

select*from employees where performance = 1;

select name,salary, nullif(salary,0) as salary_category from


employees;

select name,salary, ifnull(salary,30000) as Salary_With_Default from


employees;

select*from employees;
OUTPUT

You might also like