0% found this document useful (0 votes)
21 views4 pages

Prince ADBMS 2.1

Uploaded by

Akash Raj
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)
21 views4 pages

Prince ADBMS 2.1

Uploaded by

Akash Raj
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/ 4

EXPERIMENT2.

ADVANCE DATABASE MANAGEMENT SYSTEM Lab

Student Name: Akash Raj Subject Code: 22CAP637

UID: 22MCI10178 Section/Group: 22MAM-


2_B

Semester: 1st Semester Date of Performance: 08/1


/22
Aim
Query the two cities in STATION with the shortest and longest CITY
names, as well as their respective lengths(i.e. number of characters in
the name). If there is more than one smallest or largest city, choose
the one that comes first when ordered alphabetica ly.
The STATION table is described as fo lows:
Field Type

ID NUMBER

CITY VARCHAR2(2
1)
STATE VARCHAR2(
2)
LAT_N NUMBER

LONG_ NUMBER
W

Where LAT_N is the northern latitude and LONG_W is the western


longitude.
Solution
Query for creating the table:-

Create table STATION (ID int, CITY varchar2(21), STATE varchar2(2), LAT_N
int, LONG_W int);

INSERT INTO STATION VALUES(1, 'Kasganj',

'UP', 24, 74); INSERT INTO STATION VALUES(2,


'Bareilly', 'UP', 26, 80); INSERT INTO STATION

VALUES(3, 'Mumbai', 'MH', 19, 72);


INSERT INTO STATION VALUES(4, 'Ludhiana', 'PB',

24, 74); INSERT INTO STATION VALUES(5,

'Hydrabad', 'TN', 21, 70); INSERT INTO STATION

VALUES(6, 'Ahemdabad', 'GJ', 27, 76); INSERT INTO

STATION VALUES(7, 'Dehradun', 'UK', 17, 50);

INSERT INTO STATION VALUES(8, 'Nagaland', 'NL',

5, 45); INSERT INTO STATION VALUES(9, 'Pilani',

'RJ', 56, 11); SELECT * FROM STATION;

Output of the table query

Query to print the largest and smallest city.

For the largest city

select CITY, length(CITY) from (select CITY, length(CITY) from station order
by length(CITY) desc) where rownum = 1;

Output

For the smallest city name

select CITY, length(CITY) from (select CITY, length(CITY) from station order
by length(CITY)) where rownum = 1;

Output
Evaluation Grid:

Sr. No. Parameters Marks Obtained Maximum Marks


1. Demonstration and Performance 5
(Pre Lab Quiz)

2. Worksheet 10
3. Post Lab Quiz 5

You might also like