Created
November 21, 2008 20:20
-
-
Save turnerking/27609 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SQL_CALC_FOUND_ROWS o.*, | |
(CASE TRUNCATE(( | |
SELECT (SUM(oi.case_or_pack)/COUNT(*)) | |
FROM order_items as oi, orders as o | |
WHERE o.order_id = oi.order_id) | |
,2) | |
WHEN 2.00 | |
THEN "CA" | |
WHEN 1.00 | |
THEN "EA" | |
ELSE "CE" | |
END) as order_type | |
FROM orders AS o' | |
WHERE o.status IN (1,2,4,11); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment