Search This Blog

Wednesday, February 2, 2011

Answer to exercise Feb.3, 2011

DELIMITER $$

DROP PROCEDURE IF EXISTS `company`.`Modulusby3` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `Modulusby3`(IN parameter1 integer)
BEGIN /* start of block */

IF parameter1%3=TRUE then
Select customerName, productName, count(o.orderNumber)
from customers c, products p, orders o, orderdetails od
where c.customerNumber=o.customerNumber and p.productCode=od.productCode and o.orderNumber=od.orderNumber
group by customerName;

ELSEIF parameter1%3=1 then
Select  productName,customerName, count(o.orderNumber)
from customers c, products p, orders o, orderdetails od
where c.customerNumber=o.customerNumber and p.productCode=od.productCode and o.orderNumber=od.orderNumber
group by customerName;

ELSE
Select 'NOTHING';
END IF;

END $$

DELIMITER ;

The Answer for number2 will be posted later...

No comments:

Post a Comment