Or, could this be what you're after?
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'
DECLARE @ProcessingLookUp TABLE(Caselist VARCHAR(8), Department varchar(400), score INT);
INSERT INTO @ProcessingLookUp
SELECT '23456', 'network', 92 UNION ALL
SELECT '4321', 'network', 45
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 case when ppl.score < pl.score then ppl.score else pl.score end as minComboScore, *
from @ProcessingProductLookUp ppl
inner join @ProcessingLookUp pl
on ppl.Caselist = pl.Caselist
No comments:
Post a Comment