1

I've a feeling the answer to this question is straight forward enough but my SQL knowledge is very basic so please bear with me! I use an Excel spreadsheet to keep track of orders for my milk delivery business. I have the spreadsheet setup as a database (OBCD driver for Excel Mac 2011) and pull data from this to list orders for each of my delivery days. When I have a customer whose order is paused I'd like to have this order not appear in my list of deliveries. The current SQL query used to pull the data is:

SELECT "All Orders"."Acc ID", "All Orders"."Route ID", "All Orders"."First  Name", 
"All Orders".Surname, "All Orders".HouseNumber, "All Orders".StreetName, 
"All Orders".TownName, "All Orders"."Product Name", "All Orders".Tue, 
"All Orders".Comment FROM "All Orders" WHERE ("All Orders".Tue > 0)

I've been able to construct a query to pull data that excludes the paused orders but am having trouble constructing a subquery that will list orders for each of my delivery days (columns named Tue and Thur) and exclude paused orders:

SELECT * FROM "All Orders" WHERE "All Orders".Comment NOT LIKE '%PAUSED%' OR 
"All Orders".Comment IS NULL

This pulls in rows for both delivery days, I'm looking for a way to get all orders for Tue/Thur excluding rows with paused orders. (I have a seperate page for Thur so can amend the query as necessary). Thanks in advance guys.

1 Answer 1

0

If I understand your question properly, you are looking to modify the first query to simply filter out the paused orders. To do this, you can add an additional condition in the WHERE clause.

SELECT 
  "All Orders"."Acc ID", 
  "All Orders"."Route ID", 
  "All Orders"."First  Name", 
  "All Orders".Surname,
  "All Orders".HouseNumber, 
  "All Orders".StreetName, 
  "All Orders".TownName,
  "All Orders"."Product Name",
  "All Orders".Tue, 
  "All Orders".Comment
FROM "All Orders" 
WHERE ("All Orders".Tue > 0) 
  AND ("All Orders".Comment NOT LIKE '%PAUSED%' OR "All Orders".Comment IS NULL)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.