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

dddf

Uploaded by

Kakarot
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

dddf

Uploaded by

Kakarot
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Practical File

Informatics Practices
By: Arush Gupta
Class XI NM B
BCM Arya Model Sr. Sec. School

TO: Ms. Ambica Soni


SQL Queries

a. Display all the records (all columns) from the employee table.
SELECT * FROM Emp;

a. Display all the records (all columns) from the employee table.
SELECT * FROM Emp;

b. Display EmpNo and EName of all employees from table Emp.


SELECT EmpNo, EName FROM Emp;
c. To list all names, sorted alphabetically of all employees.
SELECT EName FROM Emp ORDER BY EName;

d. To display the employee name and the incremented value of SAL as SAL
+ 300.
SELECT EName, Sal + 300 AS IncrementedSalary FROM Emp;

e. To list the employee name and its annual salary (Annual salary = 12 *
Sal + 100).
SELECT EName, (12 * Sal + 100) AS AnnualSalary FROM Emp;

f. Display the EName and Sal where Comm is NULL.


SELECT EName, Sal FROM Emp WHERE Comm IS NULL;

g. To list the distinct department numbers from the table.


SELECT DISTINCT DeptNo FROM Emp;

h. To list the unique jobs from the table.


SELECT DISTINCT Job FROM Emp;

i. To list the salary where salary is less than the commission.


SELECT Sal FROM Emp WHERE Sal < Comm;

j. Display employee name and salary of those employees who don’t have
their salary in the range of 25000 to 40000.
SELECT EName, Sal FROM Emp WHERE Sal NOT BETWEEN 25000 AND
40000;

k. To list the EmpNo which are IN 7902, 7566, 7788.


SELECT EmpNo FROM Emp WHERE EmpNo IN (7902, 7566, 7788);

l. To list the EName starting with 'S'.


SELECT EName FROM Emp WHERE EName LIKE 'S%';
m. To list the EName and salary of employees whose salary is greater than
or equal to 2200.
SELECT EName, Sal FROM Emp WHERE Sal >= 2200;

n. Display name, job, salary, and hiredate of employees hired between


May 20, 1991, and December 31, 2001, in ascending order of hiredate.
SELECT EName, Job, Sal, Hiredate FROM Emp WHERE Hiredate
BETWEEN '1991-05-20' AND '2001-12-31' ORDER BY Hiredate;

o. Display the name of employees who have 'L' as any alphabet of their
name.
SELECT EName FROM Emp WHERE EName LIKE '%L%';

p. Display the employee name and job of employees hired between Feb
20, 1991, and Dec 31, 1991.
SELECT EName, Job FROM Emp WHERE Hiredate BETWEEN '1991-02-
20' AND '1991-12-31';

q. Display the EName and DeptNo of all employees in departments 20 and


30 in alphabetical order by name.
SELECT EName, DeptNo FROM Emp WHERE DeptNo IN (20, 30) ORDER
BY EName;

r. List the EName and salary of all the employees who earn more than
1200 and are in department 10 or 40.
SELECT EName, Sal FROM Emp WHERE Sal > 1200 AND DeptNo IN (10,
40);

s. List name and hiredate of all the employees who are hired in 1981.
SELECT EName, Hiredate FROM Emp WHERE Hiredate LIKE '1981%';

t. To list all the employees who do not have a manager.


SELECT * FROM Emp WHERE Manager IS NULL;

u. To list name and salary of all employees who earn a commission.


SELECT EName, Sal FROM Emp WHERE Comm IS NOT NULL;
v. To list the names of all employees where the second letter of their
name is an 'A'.
SELECT EName FROM Emp WHERE EName LIKE '_A%';

w. To list the names and jobs of all employees who work in department
20 and their manager is 7788.
SELECT EName, Job FROM Emp WHERE DeptNo = 20 AND Manager =
7788;

x. Display distinct salaries from table Emp.


SELECT DISTINCT Sal FROM Emp;

y. Create a query that produces a display in the format <employee name>


earns <salary> monthly and working as <job> from table Emp.
SELECT CONCAT(EName, ' earns ', Sal, ' monthly and working as ', Job)
AS Details FROM Emp;

z. Display EName joined with Job with the heading "Employee, Sal * 12 as
'Total Salary'" from table Emp.
SELECT CONCAT(EName, ', ', Job) AS Employee, Sal * 12 AS TotalSalary
FROM Emp;

aa. Write a query to display EName and Sal of employees whose salary is
greater than or equal to 13000 from table Emp.
SELECT EName, Sal FROM Emp WHERE Sal >= 13000;

ab. Write a query to display employee name, salary, and department


number who are not getting commission from table Emp.
SELECT EName, Sal, DeptNo FROM Emp WHERE Comm IS NULL;

(ac) Display employee number, name, salary, and annual salary


where commission is not NULL

SELECT EMPNO, ENAME, SAL, (SAL * 12) AS Annual_Salary FROM EMP


WHERE COMM IS NOT NULL;

(ad) Display employee name and salary for employees whose


salary is not between 11500 and 13000
SELECT ENAME, SAL FROM EMP WHERE SAL NOT BETWEEN 11500
AND 13000;

(ae) Display name, job, salary, and hire date of employees hired
between February 20, 1991, and May 1, 1991, in ascending hire
date order

SELECT ENAME, JOB, SAL, HIREDATE FROM EMP WHERE HIREDATE


BETWEEN '1991-02-20' AND '1991-05-01' ORDER BY HIREDATE ASC;

(af) Display name and hire date of all employees hired in 1992

SELECT ENAME, HIREDATE FROM EMP WHERE YEAR(HIREDATE) =


1992;

(ag) Display name of employees whose name contains 'A' as the


third alphabet

SELECT ENAME FROM EMP WHERE ENAME LIKE '__A%';

(ah) Display name of employees whose name ends with 'T'

SELECT ENAME FROM EMP WHERE ENAME LIKE '%T';

(ai) Display name of employees whose name contains 'M' as the


first alphabet and 'L' as the third alphabet

SELECT ENAME FROM EMP WHERE ENAME LIKE 'M_L%';

(aj) Display name of employees who have 'L' as any alphabet in


their name

SELECT ENAME FROM EMP WHERE ENAME LIKE '%L%';

(ak) Display employee number, name, salary, and salary increased


by 15%, labeled as New Salary

SELECT EMPNO, ENAME, SAL, ROUND(SAL * 1.15) AS New_Salary FROM


EMP;
(al) Display employee name and salary review date, which is six
months after the hire date

SELECT ENAME, DATE_ADD(HIREDATE, INTERVAL 6 MONTH) AS


Salary_Review_Date FROM EMP;

(am-i) Output the name and calculated annual income for Ashok
Singhal

SELECT ENAME, 12 * SAL + COMM FROM EMP WHERE ENAME = 'Ashok


Singhal';

(am-ii) Output the names of employees whose name starts with


any character and 'a' as the second character

SELECT ENAME FROM EMP WHERE ENAME LIKE '_a%';

(am-iii) Output the names of employees whose manager is NULL

SELECT ENAME FROM EMP WHERE MGR IS NULL;

(am-iv) Count the number of employees in department 20

SELECT COUNT(*) FROM EMP WHERE DEPTNO = 20;

(am-v) Count the number of employees with non-NULL COMM


values in department 20

SELECT COUNT(COMM) FROM EMP WHERE DEPTNO = 20;

Python
Program:

Write a program to enter

names of employees and their salaries

as input and store them in a dictionary.


# Program to create a dictionary that stores names of employees and their salaries

num = int(input("Enter the number of employees whose data to be stored: "))

employee = dict() # Create an empty dictionary

for count in range(num):

name = input("Enter the name of the Employee: ")

salary = int(input("Enter the salary: "))

employee[name] = salary

print("\n\nEMPLOYEE_NAME\tSALARY")

for k in employee:

print(k, '\t\t', employee[k])

Program:

Write a program to count the number

of times a character appears in a given


string.

#Count the number of times a character appears in a given string

# Count the number of times a character appears in a given string

st = input("Enter a string: ")

dic = {} # Create an empty dictionary

for ch in st:

if ch in dic:

dic[ch] += 1

else:

dic[ch] = 1

for key in dic:

print(key, ':', dic[key])

Program:

Write a program to convert a number

entered by the user into its corresponding

number in words. for example if the input

is 876 then the output should be ‘Eight


Seven Six.

# Program to convert a number entered by the user into its corresponding number
in words

num = input("Enter any number: ") # Number is stored as a string

numberNames = {

0: 'Zero', 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four',

5: 'Five', 6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine'

result = ''

for ch in num:

key = int(ch) # Convert character to integer

value = numberNames[key]

result = result + ' ' + value

print("The number is:", num)

print("The numberName is:", result.strip())

You might also like