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

SQL Question Bank Solution-Two-Most-Repeated

Uploaded by

irfan joni
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)
6 views

SQL Question Bank Solution-Two-Most-Repeated

Uploaded by

irfan joni
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/ 3

DU AIS 28 – Section B

Question-03
c) Writing SQL code:
i. Create a table called “customer_information” that has attributes – customer_id, customer_name,
customer_location

create table customer_information


(
customer_id int auto_increment primary key,
cutomer_name varchar(40) default "Baap e kono naam deynai",
customer_location varchar(50)
);

ii. Find out the – sales, sales_person, transaction_id & region from the table- transactions where the
sales amount is greater than BDT 10,000

select sales, sales_person, transaction_id, region from transactions where sales >10000;

iii. Make a query & display – customer_name, address, postal_code, country from the table –
customer_information, also order the output according to customer_name in the ascending
alphabetical order

select customer_name, address, postal_code, country from customer_information order by


customer_name;
DU AIS 28 – Section B

iv. Add a new column named customer_review to the table- customer_information, considering
reviews can be given only on the scale of 1 to 5

alter table customer_information


add column customer_review int(1) check(customer_review >=1 and customer_review <=5);

v. Make an entry to the table – customer_information. Use hypothetical values

Output:

insert into customer_information values


(12901,"Bhaag Milka Bhaag","Dhaka, Bangladesh");
DU AIS 28 – Section B

Question 2 – Relational – doing queries on multiple tabled database


d) first create a database that has two tables:
table 01: employee_table
columns: employee_id, employee_name, department, employee_position
i) Display the information (employee_id, employee_name, department, employee_position) of
employees whose employee_id are in between 4 & 9

select * from employee_table where employee_table.employee_id between 4 and 9;


ii) Display the information (employee_id, employee_name, month_name, basic_salary) of
employees whose salary is above 50,000 BDT, and who works in finance department

select employee_table.employee_id, employee_table.employee_name,


salary_table.month_name, salary_table.basic_salary from employee_table
join salary_table on employee_table.employee_id = salary_table.employee_id
where salary_table.basic_salary >50000
group by employee_table.employee_id, employee_table.employee_name,
salary_table.month_name, salary_table.basic_salary;

iii) Display the information (employee_id, employee_name, month_name, basic_salary) of


employees whose salary is in between 50,000 and 80,00 BDT

select employee_table.employee_id, employee_table.employee_name,


salary_table.month_name, salary_table.basic_salary from employee_table
join salary_table on employee_table.employee_id = salary_table.employee_id
where salary_table.basic_salary between 50000 and 80000
group by employee_table.employee_id, employee_table.employee_name,
salary_table.month_name, salary_table.basic_salary;

You might also like