DJCMBear
10-18-2011, 10:50 AM
Hello
Just trying to Join two tables along with ordering and counting from one table I have gotten so far but not close enough lol. Here is what I have right now.
SELECT `orders`.`Date`, COUNT(`orders`.`Date`) As `Count`, `franchises`.`Calendar`
FROM `orders`
JOIN `franchises` ON `franchises`.`ID` = `orders`.`Franchise`
WHERE `orders`.`Date` <> '' && `orders`.`Date` > :DATE && `orders`.`Franchise` = :FRANCHISE
GROUP BY `orders`.`Date`
HAVING COUNT(`orders`.`Date`) < `franchises`.`MaxOrders`
ORDER BY `orders`.`Date`
The bit I get an error on is the HAVING clause which I need to obtain the max-orders which the specific franchise has set which could be like '5' orders at max, now I need to count the amount of jobs which are per each date so like on '20-10-2011' could have '3' jobs and '21-10-2011' could have '10' jobs now if the franchise has set their max-orders to '10' i don't want the second date to show up in the results has that has hit the max amount of jobs on a date, how can I do this?
Thank you
- DJCMBear
Just trying to Join two tables along with ordering and counting from one table I have gotten so far but not close enough lol. Here is what I have right now.
SELECT `orders`.`Date`, COUNT(`orders`.`Date`) As `Count`, `franchises`.`Calendar`
FROM `orders`
JOIN `franchises` ON `franchises`.`ID` = `orders`.`Franchise`
WHERE `orders`.`Date` <> '' && `orders`.`Date` > :DATE && `orders`.`Franchise` = :FRANCHISE
GROUP BY `orders`.`Date`
HAVING COUNT(`orders`.`Date`) < `franchises`.`MaxOrders`
ORDER BY `orders`.`Date`
The bit I get an error on is the HAVING clause which I need to obtain the max-orders which the specific franchise has set which could be like '5' orders at max, now I need to count the amount of jobs which are per each date so like on '20-10-2011' could have '3' jobs and '21-10-2011' could have '10' jobs now if the franchise has set their max-orders to '10' i don't want the second date to show up in the results has that has hit the max amount of jobs on a date, how can I do this?
Thank you
- DJCMBear