Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/* Query 4. Find products that satisfy BOTH conditions below: (a) Its unit price must NOT below $22. (b) Its category ID is 4 or

/* Query 4. Find products that satisfy BOTH conditions below: (a) Its unit price must NOT below $22. (b) Its category ID is 4 or 7 or 8. If its category ID is 1 or 3, then it must have at least 40 units in stock.

Display their ProductID, UnitPrice, CategoryID, and UnitsInStock. The output should be sorted by CategoryID in A -> Z order (i.e., from smallest to largest). For those with the same CategoryID, the one with the highest UnitPrice should be displayed first.

Hint 1: a compound condition with AND, OR, NOT. Hint 2: correct output has 16 products. */

Here is the SQL Query I'm using:

SELECT ProductID,UnitPrice,CategoryID,UnitsInStock FROM Products WHERE UnitPrice>=22 AND CategoryID in (4,7,8) or CategoryID in (SELECT CategoryID FROM Products WHERE CategoryID in (1,3) and UnitPrice >=40) ORDER BY CategoryID ASC;

When I run this query it outputs more than 16 products. How can I fix my issue?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions

Question

What is the difference between a group and a team?

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago

Question

10. Discuss the complexities of language policies.

Answered: 1 week ago

Question

1. Understand how verbal and nonverbal communication differ.

Answered: 1 week ago