Jump to content

SQL ERROR in phpMyAdmin


akienghie09
 Share

Recommended Posts

I have a query where I will display how many transactions are made base on the amount of each transaction. But it has an error, the error is that the last amount which is 1,000 above is the same with the total transaction. Can someone check my query? This is my query: SELECT restaurant_master.code, restaurant_master.name, COUNT(CASE WHEN mds_orders.GrossTotal < '100' THEN 1 END) AS less100, COUNT(CASE WHEN mds_orders.GrossTotal >= '100' AND mds_orders.GrossTotal < '200' THEN 1 END) AS less200, COUNT(CASE WHEN mds_orders.GrossTotal >= '200' AND mds_orders.GrossTotal < '300' THEN 1 END) AS less300, COUNT(CASE WHEN mds_orders.GrossTotal >= '300' AND mds_orders.GrossTotal < '400' THEN 1 END) AS less400, COUNT(CASE WHEN mds_orders.GrossTotal >= '400' AND mds_orders.GrossTotal < '500' THEN 1 END) AS less500, COUNT(CASE WHEN mds_orders.GrossTotal >= '500' AND mds_orders.GrossTotal < '600' THEN 1 END) AS less600, COUNT(CASE WHEN mds_orders.GrossTotal >= '600' AND mds_orders.GrossTotal < '700' THEN 1 END) AS less700, COUNT(CASE WHEN mds_orders.GrossTotal >= '700' AND mds_orders.GrossTotal < '800' THEN 1 END) AS less800, COUNT(CASE WHEN mds_orders.GrossTotal >= '800' AND mds_orders.GrossTotal < '900' THEN 1 END) AS less900, COUNT(CASE WHEN mds_orders.GrossTotal >= '900' AND mds_orders.GrossTotal < '1000' THEN 1 END) AS less1k, COUNT(CASE WHEN mds_orders.GrossTotal > '1000' THEN 1 END) AS gtr1k, COUNT(mds_orders.GrossTotal) AS total FROM mds_orders JOIN restaurant_master ON mds_orders.RestaurantID = restaurant_master.PKID WHERE mds_orders.OrderDate BETWEEN '2011-11-01' AND '2011-11-30' GROUP BY restaurant_master.code, restaurant_master.name"; --Thanks. Best Regards. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...