Question

NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR...

NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR FOREIGN etc

Customer [ CustID, LastName, FirstName, Address, City, State, Zip, Phone, Fax, Email]

Product [ ProdID, Description, Color, Size, Pack]

Sales [ TransID, CustID, ProdID, Price, Quantity, Amount]

  1. Write SQL statement to produce a list of unique products and their prices from the Sales table. Please ensure that the products do not repeat.
  2. Write an SQL statement to list ProdID and Description for all items that cost more than $10 and less than $ 18. Hint [ Product and Sales tables have to be joined using a WHERE condition]
  1. Write an SQL statement to list out all products, their colors and their sizes where the product description ends with ‘ster’

  1. Use the SQL IN feature to generate a list of customers (lastname, firstname and address) who live in the following cities: Herndon, Seattle
  2. The company just made a new email policy which stipulates that all emails should have the following format: Last Name (7) . First Name (2) @ MIS.COM. Write a SQL statement which when run on the customer table can give an additional field names New_Email with the above mentioned format.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

A. SQL statement to produce a list of unique products and their prices from the Sales table is

select distinct ProdId ,Price from Sales

So as per the sql statement prodid and price from the sales table will be shown which is also unique. no repitition of the product will be shown because of the keyword distinct.

B.SQL statement to list ProdID and Description for all items that cost more than $10 and less than $ 18. Hint [ Product and Sales tables have to be joined using a WHERE condition] is

select ProdId, Discription from Product ,Sales where Product.ProdId = Sales.ProdId and Price Between $10 and $18.

So as per the sql statement it gives the product id and their description who have cost more than $10 and less than $ 18. Here we join the two table sales and product with cross product and gives the condition of equality of same prodid so we can say that equi join on relation wihch is written in where clause and used the between operator for the cost condition in where clause only. So the relation gives the product with cost more than $10 and less than $18.

A.  SQL statement to list out all products, their colors and their sizes where the product description ends with ‘ster’ is

Select ProdId ,Color, Size from Product where description like '%ster'.

so this sql statement gives the product id ,their color and size from the product table whoever only the description ending with ster for which we use the "like" operator in where clause to search for specific pattern in a column of description. % sign represens zero one or multipe characters.

A.Use the SQL IN feature to generate a list of customers (lastname, firstname and address) who live in the following cities: Herndon, Seattle

Select lastname,firstname,address from Customer where city in (Herndon, Seattle)

So above SQL generates a list of customers (lastname, firstname and address) who live in the following cities: Herndon, Seattle. Here we use "in" operator to give the condition to select the customer who live in Herndon, Seattle. "in " operator allows you to specify multiple values in a where clause.

B. company just made a new email policy which stipulates that all emails should have the following format: Last Name (7) . First Name (2) @ MIS.COM. Write a SQL statement which when run on the customer table can give an additional field names New_Email with the above mentioned format is

ALTER TABLE Customer  ADD New_Email varchar(20);

it will add the new field in the relation customer with named New_Email.

Add a comment
Know the answer?
Add Answer to:
NEED THE SQL QUERIES ASAP PLEASE(LIKE 1 HOUR) THE ONES WITH ID ARE PRIMARY KEYS OR...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address...

    SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address has been denormalized to include City and State for performance reasons. DeptNbr is a foreign key that references DeptNbr in the Department table Manager is a foreign key that references EmployeeID in the Employees table Data Structure: (EmployeeId, LastName, FirstName, Street, City, State, Zip, DateOfHire, DateOfBirth, JobTitle, Salary, DeptNbr(fk), Manager(fk)) TABLE: Department Business Rules: DeptNbr is defined as the primary key. Data Structure: (DeptNbr,...

  • Create the following SQL Server queries that access the Northwind database Same as problem 3 but,...

    Create the following SQL Server queries that access the Northwind database Same as problem 3 but, limit the list to all customers who placed 3 or more orders. The product id, product name, last date that the product was ordered for all items in the Grains/Cereals category. (Hint: Use MAX) The product ID, product name, and number of distinct customers who ordered that product in 1996 Thank you. Categories Customers Employees Order Details Orders Products Shippers 9 CategoryID CategoryName Description...

  • Using the database: Write SQL queries for each of the questions below. 1. Find the media...

    Using the database: Write SQL queries for each of the questions below. 1. Find the media type which has 100 or more tracks. Print the name of such media type. Number of rows returned in the result = 3 A) Find the playlists which have one or more tracks that have never been purchased in California (CA). Print the Id, and the name of such playlists. Number of rows returned in the result = 18 B) Find the customers who...

  • SQL Queries – in this assignment you will be asked to create several SQL queries relating...

    SQL Queries – in this assignment you will be asked to create several SQL queries relating to the Sakila database that we installed in class. You may freely use DBeaver to create these queries, but I will expect your solution to show me the SQL code to answer or complete the tasks below. Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include...

  • Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587...

    Prepare and execute each of the queries listed using the "Adventureworks2012" database in SQL: Server: http://msftdbprodsamples.codeplex.com/releases/view/93587 When all of your queries are complete, cut and paste the SQL Syntax into a word document. In order to see what the column names are, you need to click on the table and then Columns to see the field names. Make sure to include column headings that make sense in the queries (use the as “Field Name” after the field selected). Multi-table Queries...

  • Given the following relational schema, write queries in SQL to answer the English questions. The Access...

    Given the following relational schema, write queries in SQL to answer the English questions. The Access Database for the schema is available, as is a DDL file. It is also available on the MySQL server. You must only submit the SQL for your answers. You can get your answers without using a DBMS or by using Access or MySQL. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid:...

  • Deliverable 1. Simple SQL Statements Caution: Read the instructions carefully! Each question is based on a...

    Deliverable 1. Simple SQL Statements Caution: Read the instructions carefully! Each question is based on a single SQL statement, and the single SQL statement might contain sub-queries (additional SELECT statements) within the statement. Provide a list all of the Customer ID, Customer Names, and States and sort the list in alphabetical order by Customer Name. Provide a list of all of the Customer ID, Customer Names, and States, and sort the list by state with the Customer Names in alphabetical...

  • Customer Product Manufacturer ManufacturerID ManufacturerName Addressi Address2 City State PostalCode Phone Fax Contact URL Sale Saleltem...

    Customer Product Manufacturer ManufacturerID ManufacturerName Addressi Address2 City State PostalCode Phone Fax Contact URL Sale Saleltem CustomerID FirstName LastName StreetAddress City State PostalCode Country Phone SalelD SaleDate CustomerID Tax Shipping SaleID ProductiD ItemSize Quantity SalePrice ProductID ProductName ManufacturerID Composition ListPrice Gender Category Color Description Employee EmployeelD o FirstName LastName Address City State ZIP Phone ManagerlD SSN EmailAddress HireDate SalaryEmployee EmployeelD o Salary WageEmployee EmployeelD o Wage MaxHours What are the dollar amounts of each Sale (add all SaleItem amounts) for...

  • The primary keys are underlined. The foreign keys are denoted by asterisks (*). Description of the...

    The primary keys are underlined. The foreign keys are denoted by asterisks (*). Description of the schema: • person — keeps track of the people who borrow books from the library. The attributes contain personal and contact information. • author — keeps track of personal information about authors. • publisher — keeps track of the publisher information. To keep it simple, most of the attributes have been truncated in the sample database. 1 trivial dependencies are things like X→X or...

  • Using the tables provided above, provide SQL statements for the following queries. NOTE: YOU DO NOT NEED TO INSERT MOR...

    Using the tables provided above, provide SQL statements for the following queries. NOTE: YOU DO NOT NEED TO INSERT MORE DATA INTO THE TABLES. The list of tables available for this assignment is the following MODEL(modellD, economySeats, buisnessSeats, firstClassSeats, cargoCapacity, fuelCapacity, length, wingspan, serviceHours) LOCATION(airportCode, country, address, phone) TICKET ticketNum, luggageLimit, seatNum, classCode, medicalCondition, mealChoice, customerlD, flightID) ROUTE(routelD, description, arriveAirportCode, departAirportCode) IRREGULAR_EVENT(eventNumber,flightlD, eventDate TIme, eventDescription) SERVICE(serviceDate,airfD, description, cost) AIRCRAFT (aicraftlD, mailCargoCapacity, numMedPacks, numDefibritlators, haulType, modellD NEACC MEMBER(memberlD, flightGoldPoints) STAFF(stafflD, name,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT