Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am using Orable database 12C with MAC OS Virtual machine. After I connect SQL

ID: 3695918 • Letter: I

Question

I am using Orable database 12C with MAC OS Virtual machine.

After I connect SQL by using

sqlplus /nolog

connect sys /AS sysdba

I created the CITY table by running this SQL command.

CREATE TABLE CITY (

ID INTEGER NOT NULL,

Name NVARCHAR2(50) NOT NULL ,

CountryCode CHAR(3) NOT NULL ,

District NVARCHAR2(50) NOT NULL ,

Population INTEGER NOT NULL,

PRIMARY KEY (ID)

);

And then,

I downloaded SQL script to my computer that poulate data for the CITY table.

Can you help me with few questions?

1. Use the SQL function count() to find out how many rows are in your table. Do not use "SELECT *".

Give the SQL and the row count answer

2. Write an SQL statement to get all cities of country ARG

3.Write an SQL statement to get all cities whose population is greater than 5 millions

4.Write an SQL statement to get all cities whose population is in the range of 1 to 10 millions

Explanation / Answer

1) SQL function count() to find out how many rows are in your table. Do not use "SELECT *".:

   1) SELECT COUNT(column_name) FROM table_name;

The COUNT(column_name) function returns the number of values (NULL values will not be counted) of the specified column.

2) SELECT COUNT(*) FROM table_name;

The COUNT(*) function returns the number of records in a table.

3)SELECT COUNT(DISTINCT column_name) FROM table_name;

  The COUNT(DISTINCT column_name) function returns the number of distinct values of the specified column.

2)

3)

note: plese write your table name in the above queries and run it.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote