test percentage

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

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

--
-- Gucci | Nike | Dior
-- 40    | 40   | 20
-- 40%   | 40%  | 20%
--

SELECT
	SUM(quantity),
	clientCusSubCont
FROM
	@subContractorMarkedCode
WHERE
	codesStatus2 = 'Item Associated'
	AND (codesStatus16 = 'Cloned'
	OR codesStatus32 = 'Blocked'
    OR codesStatus64 = 'Stolen')
GROUP BY
	clientCusSubCont;

Enter Parameters

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