In reference to my previous Question . With these changes in the tables : (*) are used to mark the changes in the tables.
Products Table
prod_ID - int
prod_Name - varchar(100)
prod_Code - varchar(100)
*prod_Price- float
Orders Table
ord_ID - int
ord_Qty - int
prod_ID - int
cus_ID - float
*ord_PurchaseType - varchar(100)
Given that all items are priced as 10 dollars each. I want to make the final report to be something like this.
Currently, I'm using something like this: SUM(CASE WHEN ord_PurchaseType = 'cash' THEN prod_Price ELSE 0 END)
to get the data, It works when I run in not inside the SET @query = N' ...
query. Aside from that It is having an error saying that it has an invalid column named cash. I also tried putting the word cash in a variable but it still produces the same error.