Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

RDBMS-IV

N.SWETHA
21PA18

Table Weather
CREATE TABLE Weather(
City char(15) primary key,
Temperature number(2),
Humidity number(2),
Condition char(20),
Country char(20)
);
insert into Weather values('Washington','22','67','rainy','US');
insert into Weather values('Sydney','20','45','fog','Australia');
insert into Weather values('Dhaka','38','88','sunny','Iran');
insert into Weather values('Paris','36','85','sunny','Germany');
insert into Weather values('London','27','55','fog','UK');
insert into Weather values('Canada',35,82,'rainy','US');
insert into Weather values('Vitenam','22','42','fog','Italy');
insert into Weather values('Mascow','28','50','rainy','Russia');
insert into Weather values('Delhi','39','89','sunny','India');
insert into Weather values('Tokyo','45','76','sunny','Japan');
insert into Weather values('Manchester',31,79,'fog','UK');
insert into Weather values('Bern','12','30','fog','Switzerland');
insert into Weather values('Kerala','24','52','rainy','India');
select * from Weather;
TEMPERATUR
CITY E HUMIDITY CONDITION COUNTRY
Washington 22 67 rainy US
Sydney 20 45 fog Australia
Dhaka 38 88 sunny Iran
Paris 36 85 sunny Germany
London 27 55 fog UK
Canada 35 82 rainy US
Vitenam 22 42 fog Italy
Mascow 28 50 rainy Russia
Delhi 39 89 sunny India
Tokyo 45 76 sunny Japan
Manchester 31 79 fog UK
Bern 12 30 fog Switzerland

1. List the cities in a weather table.


QUERY:
select City from Weather;
Output:
CITY
Bern
Canada
Delhi
Dhaka
Kerala
London
Manchester
Mascow
Paris
Sydney
Tokyo
Vitenam

2. List the countries available in the table.


QUERY:
select Country from Weather group by Country;
Output:

COUNTRY
Iran
Japan
Switzerland
Australia
Germany
Russia
UK
Italy
India

3. List types of climatic conditions in this table.


QUERY:
select Condition from Weather group by Condition;
Output:

CONDITION
sunny
rainy
fog

4. List the cities which have the temperature


less than 35.
QUERY:

select City from Weather where Temperature<35;


Output:
CITY

Washington

Sydney

London

Vitenam

Mascow

Manchester

Bern

Kerala

5. List the countries where the climate condition


is rainy.

QUERY:

select Country from Weather where Condition='rainy';


Output:

COUNTRY

US

US

Russia

India
6. List the cities where the climate condition is sunny.
QUERY:
select City from Weather where Condition='sunny';
Output:
CITY
Dhaka
Paris
Delhi
Tokyo

7. List the countries and cities where the climate


condition is fog.

QUERY:

select Country, City from Weather where


Condition='fog';

Output:

COUNTRY CITY

Australia Sydney

UK London

Italy Vitenam

UK Manchester

Switzerland Bern

8. List the cities, Humidity level and weather


condition in India.
QUERY:
select City, Humidity, Condition from Weather where
Country='India';

Output:

CITY HUMIDITY CONDITION

Delhi 89 sunny

Kerala 52 rainy

9. List the cities whose temperature between 30 and


40.

QUERY:

select City from Weather where Temperature >= 30 and


Temperature <= 40;

Output:

CITY

Dhaka

Paris

Canada

Delhi

Manchester

10. List the cities in India from the weather table.


QUERY:
select City from Weather where Country='India';
Output:
CITY
Delhi
Kerala

11. List the cities which have city name start with “I”.
QUERY:
select City from Weather where City LIKE 'I%';
Output:
no data found

12. Display all cities which have the temperature between 35


and 40 and city name consists of letter ‘R’.
QUERY:

select City from Weather where Temperature>=35 and


Temperature<=40 and City like ‘%r%’;

Output:

CITY

Paris

13. List the cities where temperature is less than 25 and


weather condition is rainy.
QUERY:

select City from Weather where Temperature<25 and


Condition='rainy';
Output:
CITY
Washington
Kerala

14. List cities in UK and US where temperature is between 30


and 40.
QUERY:

select City from Weather where Country = 'US' and

Country = 'UK', Temperature>=30 and Temperature<=40;

Output:
CITY
Manchester

15. List the countries and weather condition where the


humidity is between 20 and 45.
QUERY:

select Country,Condition from Weather where Humidity>=20 and


Humidity<=45;
Output:

COUNTRY CONDITION
Australia fog
Italy fog
Switzerland fog

You might also like