test percentage

0

Please login or register to vote for this query.

(click on this box to dismiss)

Joomla Meta

Q&A about the site for Joomla! administrators, users, developers and designers

DECLARE @subContractorMarkedCode TABLE
	(quantity INTEGER,
	clientCusSubCont VARCHAR(30),
	codesStatus2 VARCHAR(30),
	codesStatus16 VARCHAR(30),
	codesStatus32 VARCHAR(30),
	codesStatus64 VARCHAR(30));
INSERT @subContractorMarkedCode
VALUES(20,'Gucci','Item Associated','Cloned','',''),
(20,'Gucci','Item Associated','','Blocked',''),
(20,'Gucci','Item Associated','','Blocked',''),
(20,'Gucci','Item Associated','','','Stolen'),
(40,'Nike','Item Associated','Cloned','',''),
(40,'Nike','Item Associated','','','Stolen'),
(40,'Dior','Item Associated','','Blocked','');

--
-- Gucci | Nike | Dior
-- 80    | 80   | 40
-- 40%   | 40%  | 20%
--
SELECT
INN_Q.SUB_QUANTITY, SUM(INN_Q.SUB_QUANTITY)
FROM
	(
		SELECT SUM(quantity) AS SUB_QUANTITY,
		clientCusSubCont
	FROM
		@subContractorMarkedCode
	WHERE
		codesStatus2 = 'Item Associated'
		AND (codesStatus16 = 'Cloned'
		OR codesStatus32 = 'Blocked'
		OR codesStatus64 = 'Stolen')
	GROUP BY
		clientCusSubCont) AS INN_Q
        group BY SUB_QUANTITY;

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results