First of all whole question is given I just need out of given queries ASAP!!       Write the SQL statements for the following User table. User_id   Name City   Order_date   Purchase_amount   101 Alex Paris 2012-10-05 150.5 102 James London 2012-10-05 270.3 103 Paul Paris 2012-10-05 120.8 104 Lawson Rome 2012-10-05 230.5 105 Kate Beijing 2012-10-05 30.2   Write a query to create a user table containing following columns. Whereas user_id as primary key. Write a query to insert multiple records into user table. Write a query to add two columns, country and currency in user table. Write a query to update user table, set city as shanghai for a user having user_id 105. Write a query to remove all records from user table. Write a query to drop a column purchase _amount from user table. Write a query to display name of user in descending order whose order purchase amount is in between 200 to 270. Write a query to display name of user who belong to either Paris, London or CS Beijing. Write query to display name of an employee who belong to paris. Write a query to display unique city name form user table.

Oracle 12c: SQL
3rd Edition
ISBN:9781305251038
Author:Joan Casteel
Publisher:Joan Casteel
Chapter12: Subqueries And Merge Statements
Section: Chapter Questions
Problem 19MC
icon
Related questions
icon
Concept explainers
Question

First of all whole question is given I just need out of given queries ASAP!!

 

 

 

Write the SQL statements for the following User table.

User_id

 

Name

City

 

Order_date

 

Purchase_amount

 

101

Alex

Paris

2012-10-05

150.5

102

James

London

2012-10-05

270.3

103

Paul

Paris

2012-10-05

120.8

104

Lawson

Rome

2012-10-05

230.5

105

Kate

Beijing

2012-10-05

30.2

 

  1. Write a query to create a user table containing following columns. Whereas user_id as primary key.
  2. Write a query to insert multiple records into user table.
  3. Write a query to add two columns, country and currency in user table.
  4. Write a query to update user table, set city as shanghai for a user having user_id 105.
  5. Write a query to remove all records from user table.
  6. Write a query to drop a column purchase _amount from user table.
  7. Write a query to display name of user in descending order whose order purchase amount is in between 200 to 270.
  8. Write a query to display name of user who belong to either Paris, London or CS Beijing.
  9. Write query to display name of an employee who belong to paris.
  10. Write a query to display unique city name form user table.

Answer

1.
create table User (User_id integer PRIMARY KEY, Name varchar(100), City varchar(100), Order_date date, Purchase_amount float);
       insert into User (User_id, Name, City, Order_date, Purchase_amount) values (101, 'Alex', 'Paris','2012-10-05',150.5);
       insert into User (User_id, Name, City, Order_date, Purchase_amount) values (102, 'James', 'London','2012-10-05',270.3);
       insert into User (User_id, Name, City, Order_date, Purchase_amount) values (103, 'Paul', 'Paris','2012-10-05',120.8);
insert into User (User_id, Name, City, Order_date, Purchase_amount) values (104, 'Lawson', 'Rome','2012-10-05',230.5);
insert into User (User_id, Name, City, Order_date, Purchase_amount) values (105, 'Kate', 'Beijing','2012-10-05',30.2);

2.
insert into User (User_id, Name, City, Order_date, Purchase_amount) values (106, 'Jackie', 'London','2012-10-05',150.6);

3.
ALTER TABLE User ADD country varchar(100);
ALTER TABLE User ADD currency varchar(100);

4.

UPDATE User SET City = 'Shanghai' WHERE User_id = 105;

5.

DELETE FROM User;

6.

ALTER TABLE User DROP Purchase_amount;

7.

SELECT Name FROM User WHERE Purchase_amount BETWEEN 200 and 270 ORDER BY Purchase_amount DESC;

8.
SELECT Name FROM User WHERE City = "Paris" OR City ="London" OR City ="Beijing";

9.

SELECT Name FROM User WHERE City = "Paris";

10.
SELECT DISTINCT City FROM User;

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Query Syntax
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.
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
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning