Table looks like this: id | order_id | price_ex | tax Example: 1 | 1000 | 22 | 17.5 2 | 1000 | 40 | 17.5 3 | 1004 | 10 | 0.0 I was hoping to query for order_id 1000 and get the total price inc tax. That's (22 * 1.175) + (40 * 1.175). But this query doesn't work: SELECT SUM(price * (1 + tax)) FROM table WHERE order_id = '1000' That gives me a huge amount. So it's probably all wrong. It's on MySQL 3.2 so no sub queries. Is there a way to retrieve the total in one go?
tax is in percentages, so divide it by 100 first SELECT SUM(price * (1 + (tax/100) ) ) FROM table WHERE order_id = '1000'
Crikey, I'm getting dumber by the day. Last week I rang Telewest because my broadband modem kept staying in stand by. Turned out there was a stand by button depressed. Now I add 1 + the damn tax which makes it 18.5 times the price. No wonder! I nominate this thread for the crappiest of the day. Sorry!