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

Program Practical

The document contains questions and code snippets related to SQL queries on various tables like persons, family, item, stationary, transaction, salesman, and batsman table. The SQL queries include selecting records, filtering records based on conditions, aggregation, sorting, inserting, deleting and updating records in the tables. It also includes Python programs to create a batsman table, insert, delete, display records from it, find a record, update age and count records in the batsman table.

Uploaded by

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

Program Practical

The document contains questions and code snippets related to SQL queries on various tables like persons, family, item, stationary, transaction, salesman, and batsman table. The SQL queries include selecting records, filtering records based on conditions, aggregation, sorting, inserting, deleting and updating records in the tables. It also includes Python programs to create a batsman table, insert, delete, display records from it, find a record, update age and count records in the batsman table.

Uploaded by

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

Q): Write the program for factorical of the number.

Code:-

Output:
Q): Write a program to check weather the number is armstrong
number or not.
Code:-

Output:-
Q): write program to convert temp to ferhenite & Celcius.
Code:-

Output:-
Q): Write program to print half pyramid pattern.
Code :-

Output:-
Q): Write python program for adding two lists in python.
Code:-

Output:-
Text inside “test1”:-

Q): Write a program to read first 10 Characters of a Text File.


Code:-

Output:-

Q): Write a program to read entire content of a text file.


Code :-

Output:-
Q): Write a program to read entire content of a text file along with
frequency of letter “a” in it.
Code :-

Output :-
Q): Write to read entire content of a text file along with frequency of
vowels in it.
Code:-

Output:-

Q): Write a program to read first 1 line at a time from a text file.
Code:-

Output:-
Q): Write a program using readline function to read all lines from a file
one by one.
Code:-

Output:-

Q): Write a program using readline function to read a file line by line &
count how many lines are beginning with letter w also print them.
Code:-

Output:-
Q): Write a python program to create a table batsman in test named
database.
Code:-

Output:-
Q): Write a python program to insert into the table batsman.
Code:-

Output:-
Q): write a python program to delete data from the table
batsman.
Code:-

Output:-
Q): write a python program to display all records of the table
batsman.
Code:-

Output:-
Q): Write a program to find a record in the table batsman.
Code:-

Output:-
Q): Write a program to update age in the table batsman.
Code:-

Output:-
Q): Write a program to count records in the table batsman.
Code:-

Output:-
STUDENT

Write the SQL Queries for the following questions.

i. To display the records from table student in alphabetical order as per the name

Student.

Command : Select * from student order by name;

ii. To display class dob and city whose marks is between 450 and 551.

Command : select name,class,dob,ciy from student where marks between 450 and 5
iii. To display name,class and total number of student who has scored more than 450
marksclasswise.

Command : select class,count(*) from student where marks>450 group by class:

iv. To display details of student which contains a in their

name .

Command : select * from student where name like


Transacations

Q): Write the SQL queries for the following.


(i) To display the details of all transactions of type credit from table

transaction.

Command : select * from transaction where type=”credit”;

(ii) To display the cno and amount of all transactions done in the month of September
2017from the transaction.

Command : select cno,amount from transaction where dot

like”2017-09%”;
(iii) To display the last date of transaction(dot) from the table transaction for
thecustomer having cno as 103.

Command : select max(dot) from transaction where

cno=103;

(iv) To display the cno , number of transactions and the highest amount of
eachcustomer if the number of transactions is more then 1.

Command : select cno,count(*),max(amount) from transaction group by cno


havingcount(*)>1;
Salesman

Q): Write SQL queries for the


following. (i)Count the total number

of salesman.Query-select

count(*)from salesman; Output-

(ii) Display the maximum qtysold from each area.

Query-select max(qtysold),area from salesman group by

area;Output-
(iii) Display the average qtysold from each area where where number of salesman is more
thenone.

Query-select avg(qtysold),area from salesman group by area

havingcount(sname)>1;Output-

(iv) Display all the records in ascending order of the

area.Query- select*fro salesman order by area;

Output-
ITEM

Q): Write SQL queries for the following.


(i) Display all the records on descending order of stock

date.Query-select * from item order by stockdate desc;

Output-

(ii) Display the type and total number of items of each

type. Query-select type,count(itemname) from item group

by type;Output-
(iii) Display the least price.

Query-select min(price) from

item;Output-

(iv) Display item name with their price rounded to I decimal

place.Query-select itemname, round(price,1) from item;

Output-
STATIONARY

Q): Write SQL queries for the following.


(i) Display of all the items in the stationary table in ascending order of

lastbuy.Query-select *from store order by lastbuy;

Output-

(ii) Display itemno and itemname of those items from stationary table, whose rate is more
than15.

Query-select itemno,item from stationary where

rate>15;Output-
(iii) To display the details of those items whose scode is 22 or qty is more than 110 from
thetable stationary.

Query-select * from where scode=22 or

qty>110;Output-

(iv) Display the item with its quantity which include pen in their

name.Query- select item,qty from stationary where item

like”%pen%”; Output-
FAMILY

Q): Write SQL queries for the following.


(i) To select all the information of family whose occupation is

service.Query-select * from family where occupation=”service”;

Output-

(ii) To list the name of family where female members are more

than 3.Query-select name from family where female member>3;

Output-
(iii) To count the number of family whose income is less then

10000.Query- select count(*) from family where income

<10000;

Output-

(iv) To display details of family where income is more than 10000 and occupation is mixed

type.Query- select * from family where income>10000 and occupation=”mixed”;

Outpu
1- Create table persons with attributes person name, person id, city, state, age?

2- Write a command to show the structure of a table persons.


3-Insert values into table persons according to your choice using insert method line by line.
4-Write a query in mysql show all the records from the table persons.

5-write a query in sql to show details of persons who contain e in their name.

6-write a query in sql of persons who belong to mp.


Q): Write a python program to create a table batsman
in test named database .

Output>
Q): Write a python program to insert into the table
batsman .

Output>
Q): write a python program to delete data from the
table batsman.

Output>
Q): write a python program to display all records of
the table batsman.

Output>
Q): Write a program to find a record in the table
batsman.

Output>
Q): Write a program to update age in the table
batsman.

Output>
Q): Write a program to count records in the table
batsman.

Output>

You might also like