Well I have a few questions and I like to make sure I am understanding what I am doing. So here it is I am working on a project and I am suppose to Create a variable called MinOrder and populate it with the smallest line item amount after discount for the Northwind CustomerNo ‘ALFKI’ (Careful: we’re dealing with currency here, so don’t just assume you’re going to use an int.) Output the final value of MinOrder. Now this is what I have:
Use Northwind Declare @MinOrder money; Set @MinOrder = (Select MIN(UnitPrice) From [Order Details]); Select @MinOrder
I notice that I didn't put in the ALFKI. Well I seen it said not use really use the int. I went and declare the minorder because it does with a variable and then I am taking that variable using it for the unitprice even though it says discount but when I try to put discount there it showed a red error. I am wounder if I should use another set to do the customerId = ALFKI or if I can throw it into this code. I know my code might be way off but thats why I am posting it so I can have an understanding when it comes to this only because it is a part of programming. Thanks
preguntado el 08 de noviembre de 11 a las 15:11
SET @MinOrder = SELECT MIN(UnitPrice) FROM [Order Details] WHERE CustomerNumber = 'ALFKI'
CustomerNumber with the name of the customer number field.
SELECT @MinOrder = MIN(UnitPrice) FROM [Order Details] od INNER JOIN Orders o ON o.order_ID = od.order_ID INNER JOIN Cusomers c ON c.customer_ID = o.customer_ID WHERE c.customer_code = 'ALFKI';