Hey guys, having some issues with this week\'s database problems. I have the fir
ID: 666887 • Letter: H
Question
Hey guys, having some issues with this week's database problems. I have the first set done, that was easy, and have the code for the last answer but I am receiving this error: An expression of non-boolean type specified in a context where a condition is expected, near 'REGEXP'.
SELECT Name, SalesPersonID
FROM Sales.Store WHERE Name REGEXP '^[g-j].*$' AND SalesPersonID>283
ORDER BY Name;
Lab:
1. Using the AdventureWorks database, query “Sales.SalesOrderDetail” table to find out the total number of parts associated with each of the followingSalesOrderIDs: 43660, 43670, and 43672. This task should be completed in a single query.
2. Submit the SQL statement used to accomplish this task.
1.How many rows were affected?
2. Provide a screenshot of the result set.
3. Query “Sales.Store” table to obtain the list of “Name” and “SalesPersonID” where the store name starts with the letters “g” through “j” and the SalesPersonID is greater than 283. Make sure that the list is sorted by “SalesPersonID” and then by “Name” fields in a descending order. Be sure the query returns all the required rows.
1. Submit the SQL statement used to accomplish this task.
2. How many rows were affected?
3. Provide a screenshot of the result set.
Hint: Combine WHERE clause conditions and also have an ORDER BY clause in place.
Explanation / Answer
1. select * from sale.salesorderdetail where (salesorderid =43660 or salesorderid = 43670 or salesorderid=43672)
2.It depens on the table. All the rows with the given 3 values will be displayed. however there won't be any change in the database with this query.
3.
SELECT Name, SalesPersonID
FROM Sales.Store WHERE Name REGEXP '^[g-j]$' AND SalesPersonID>283
ORDER BY Name;