/* (5) Question #2: Fix the following query. It should return
13 rows, first one is "USB food flash drive - banana"
*/
SELECT
SI.StockItemID,
SI.StockItemName AS [ItemForSales],
SI.ColorID AS [Color]
FROM
Warehouse.StockItems SI
ORDER BY
ItemForSales
WHERE
SI.ColorID = NULL
AND
SI.StockItemName LIKE '%USB%'
my error :
Msg 156, Level 15, State 1, Line 12
Incorrect syntax near the keyword 'WHERE'.
What is causing my error?
Problem is with incorrect placement of WHERE clause in the query.
First SQL query fetches all the rows that are satisfying the condition present in WHERE clause and then result set is sorted based on expression/column(s) specified in ORDER BY clause.
Syntax of an SQL query with ORDER BY clause:
SELECT column1, column2, ....
FROM <table_name>
WHERE <condition>
ORDER BY <column1, column2, ...>
<ASC|DESC>;
By default if order(ASC|DESC) is not specified results are sorted in Ascending order.
NULL Values are usually Compared as: IS NULL (or) IS NOT NULL
Updated
Query:
SELECT
SI.StockItemID,
SI.StockItemName AS [ItemForSales],
SI.ColorID AS [Color]
FROM
Warehouse.StockItems SI
WHERE
SI.ColorID IS NULL
AND
SI.StockItemName LIKE '%USB%'
ORDER BY
ItemForSales
/* (5) Question #2: Fix the following query. It should return 13 rows, first one is...
1) Consider the following Java program: 1 public class HelloWorld { 2 // My first program! 3 public static void main(String[] args) { 4 System.out.println("Hello, World!"); 5 } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...
In your judgement, and given only the facts described in this case, should the management of Massey energy Company be held morally responsible for the deaths of the 29 miners? Explain in detail. Suppose that nothing more is learned about the explosion other than what is described in this case. Do you think Don Blankership should be held morally responsible for the deaths of the 29 miners? Explain in detail. Given only the facts described in this case, should the...
10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...