You are on page 1of 2

Tools for Analytics

Assignment – 3
MM: 25

Roll No: 20PGDM082 Student Name: Lucky Mishra

Employees

Field Name Data Type Not Null Keys


emp_id integer Y Primary Key
emp_name varchar(30) Y
job varchar(30) Y
mgr_id integer N
salary integer Y
commission integer N

Q1) Based on the above figure & details write SQL to make table in mysql?

Hint: write SQL in ms-Word only with correct syntax. Test your query in mysql before-hand.

create database emp;

use emp;

CREATE TABLE employee_table(

emp_id int NOT NULL ,

emp_name varchar(45) NOT NULL,

job varchar(35) NOT NULL,

Mgr_id int NULL,

Salary int Not null,

Commission int Null,

PRIMARY KEY (emp_id)

);
Employees

emp_id emp_name job mgr_id salary commission


56990 Francis Manager 90000 5000
56891 Jokas Clerk 56990 35000
56123 Kim Analyst 56990 75000 1500

Q2) On the basis of above figure, write SQL as per mysql syntax to insert data in the employee
table?

Insert into employee_table

values ('56990', 'Francis', 'Manager', NULL , '90000', '5000');

Insert into employee_table

values('56891', 'Jokas', 'Clerk', 56990 ,'35000',NULL);

Insert into employee_table

values('56123', 'Kim', 'Analyst', 56990 ,'75000','1500');

Q3) Write SQL as per mysql syntax to display all data from employee table who are earning some
commission, at the same time have salary less than 90000?

SELECT *

FROM employee_table

WHERE Salary < 90000

and Commission is not null;

You might also like