Create the following tables in your database with the following schema: Table: Countries | Column Name | Туре | country_id I country_name +---- | int | varcharI -----+---------+ country_id is the primary key for this table. Each row of this table contains the ID and the name of one country. Table: Weather ------ | Column Name 1 Туре I ---- I country_id | weather state | int I day | int | date | +- +------+ (country_id, day) is the primary key for this table. Each row of this table indicates the weather state in a country for one day. Add the following data to your tables: Input: Countries table: +------------ I country_id | country_name | | USA | Australia | Peru I China | Morocco | Spain | 2 Weather table: +---------- | country_id | weather_state | day | 2019-11-01 | | 2019-10-28 | | 2019-10-27 | | 2019-11-10 | | 2019-11-11 | | 2019-11-12 | | 2019-11-07 I | 2019-11-09 | | 2019-11-23 | | 2019-11-28 | | 2019-12-01 | | 2019-12-02 | | 2019-11-05 | | 2019-11-15 | | 2019-11-25 | | 2019-10-23 | | 2019-12-23 | | 2 | 2 | 2 | 15 | 12 | 12 | -2 | 3 | 16 | 18 | 21 | 25 | 22 | 20 | 25 | 27 | 31 | 7 1 3

Oracle 12c: SQL
3rd Edition
ISBN:9781305251038
Author:Joan Casteel
Publisher:Joan Casteel
Chapter13: Views
Section: Chapter Questions
Problem 4MC
icon
Related questions
Question

code of create table and insert table only please

Create the following tables in your database with the following schema:
Table: Countries
+-
| Column Name
Туре
| country_id
| country_name
| int
| varcharI
-------+
country_id is the primary key for this table.
Each row of this table contains the ID and the name of one country.
Table: Weather
+-----
| Column Name
| Type |
country_id
| weather state
| day
| int
int
| date |
+-
+------+
(country_id,
Each row of this table indicates the weather state in a country for one day.
day) is the primary key for this table.
Add the following data to your tables:
Input:
Countries table:
+-
-----
| country_id | country_name |
+
| 2
| 3
| USA
| Australia
| Peru
I China
| Morocco
| Spain
| 5
+-
Weather table:
+--
| country_id | weather_state | day
| 2
| 2
| 2
| 3
| 3
| 3
| 5
| 5
| 5
| 7
| 7
| 3
| 16
| 18
| 21
| 25
| 22
| 20
| 25
| 27
| 31
| 15
| 12
| 12
| -2
| 2019-11-07 |
| 2019-11-09 I
| 2019-11-23 |
| 2019-11-28
| 2019-12-01 |
| 2019-12-02 |
| 2019-11-05 |
| 2019-11-15 |
| 2019-11-25 |
| 2019-10-23 |
| 2019-11-01
| 2019-10-28
| 2019-10-27
| 2019-11-10 |
| 2019-11-11
| 2019-11-12
| 8
| 9
| 3
2019-12-23
Transcribed Image Text:Create the following tables in your database with the following schema: Table: Countries +- | Column Name Туре | country_id | country_name | int | varcharI -------+ country_id is the primary key for this table. Each row of this table contains the ID and the name of one country. Table: Weather +----- | Column Name | Type | country_id | weather state | day | int int | date | +- +------+ (country_id, Each row of this table indicates the weather state in a country for one day. day) is the primary key for this table. Add the following data to your tables: Input: Countries table: +- ----- | country_id | country_name | + | 2 | 3 | USA | Australia | Peru I China | Morocco | Spain | 5 +- Weather table: +-- | country_id | weather_state | day | 2 | 2 | 2 | 3 | 3 | 3 | 5 | 5 | 5 | 7 | 7 | 3 | 16 | 18 | 21 | 25 | 22 | 20 | 25 | 27 | 31 | 15 | 12 | 12 | -2 | 2019-11-07 | | 2019-11-09 I | 2019-11-23 | | 2019-11-28 | 2019-12-01 | | 2019-12-02 | | 2019-11-05 | | 2019-11-15 | | 2019-11-25 | | 2019-10-23 | | 2019-11-01 | 2019-10-28 | 2019-10-27 | 2019-11-10 | | 2019-11-11 | 2019-11-12 | 8 | 9 | 3 2019-12-23
Write an SQL query to find the type of weather in each country for November 2019.
The type of weather is:
• Cold if the average weather_state is less than or equal 15,
• Hot if the average weather_state is greater than or equal to 25, and
• Warm otherwise.
Return result table in any order.
The results should be:
Output:
+-
I country_name | weather_type
| USA
| Australia
| Peru
| Morocco
| China
| Cold
I Cold
| Hot
| Hot
I Warm
Explanation:
Average weather_state in USA in November is (15) /1= 15 so weather type is Cold.
Average weather_state in Austraila in November is (-2 + 0 + 3) /3 = 0.333 so weather type is Cold.
Average weather_state in Peru in November is (25) / 1 = 25 so the weather type is Hot.
Average weather_state in China in November is (16 + 18 + 21)/3 = 18.333 so weather type is Warm.
Average weather_state in Morocco in November is (25 + 27+31)/3 = 27.667 so weather type is Hot.
We know nothing about the average weather_state in Spain in November so we do not include it in
the result table.
Transcribed Image Text:Write an SQL query to find the type of weather in each country for November 2019. The type of weather is: • Cold if the average weather_state is less than or equal 15, • Hot if the average weather_state is greater than or equal to 25, and • Warm otherwise. Return result table in any order. The results should be: Output: +- I country_name | weather_type | USA | Australia | Peru | Morocco | China | Cold I Cold | Hot | Hot I Warm Explanation: Average weather_state in USA in November is (15) /1= 15 so weather type is Cold. Average weather_state in Austraila in November is (-2 + 0 + 3) /3 = 0.333 so weather type is Cold. Average weather_state in Peru in November is (25) / 1 = 25 so the weather type is Hot. Average weather_state in China in November is (16 + 18 + 21)/3 = 18.333 so weather type is Warm. Average weather_state in Morocco in November is (25 + 27+31)/3 = 27.667 so weather type is Hot. We know nothing about the average weather_state in Spain in November so we do not include it in the result table.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Single Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781285196145
Author:
Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning