Thursday, May 29, 2014

help with query

.... I'm sorry to see you're not feeling well, but please try not to throw up on the forums.



DECLARE @Processing TABLE(CaseDataKey INT IDENTITY(1,1)PRIMARY KEY, Caselist VARCHAR(8));
DECLARE @ProcessingProduct TABLE(ProductDataKey INT IDENTITY(1,1) PRIMARY KEY, ProductCode VARCHAR(8));
INSERT INTO @Processing(Caselist)
SELECT '23456' UNION ALL
SELECT '4321'
INSERT INTO @ProcessingProduct(ProductCode)
SELECT '600' UNION ALL
SELECT '500'

SELECT * FROM @Processing
select * FROM @ProcessingProduct

DECLARE @ProcessingLookUp TABLE(Caselist VARCHAR(8), Department varchar(400), score INT);

INSERT INTO @ProcessingLookUp
SELECT '23456', 'network', 92 UNION ALL
SELECT '4321', 'network', 45

SELECT * FROM @ProcessingLookUp

DECLARE @ProcessingProductLookUp TABLE(Caselist VARCHAR(8),ProductCode VARCHAR(8) ,score INT);


INSERT INTO @ProcessingProductLookUp
SELECT '23456', '600', 60 UNION ALL
SELECT '23456', '500', 50 UNION ALL
SELECT '4321', '600', 65 UNION ALL
SELECT '4321', '500', 72

SELECT * FROM @ProcessingProductLookUp

--final score for 23456 should be 50 (It should first pick the minimum of combination caselist and product code which is 50 .And then try to comapre this with caselist and department score .so out of 50 and 92 it would be 50
--4321 score should be 45

Are we supposed to use the scores from @ProcessingLookUp, or @ProcessingProductLookUp ?

No comments:

Post a Comment