Hello Techie,
may any one please help me how to solve this puzzle Please.
/*
Rules
The resultset should appear only when fulfill all three criteria
1ST : For a group of Tree , seed, flower and Year there should always more than one distinct FLRNO
2ND: The number of FLRNO in a group of Tree , seed, flower and Year should available with all available comment 1 in the group
3rd: For a group of Tree , seed, flower and Year, the number of all comment 3, will also available with all comment1
Tree Banana will be in output, as group of Tree , seed,flower and Year have two distinct FLRNO which are available with all available comment1 in the group and comment 2 is also available with all available comment 1
Tree Mango should not be in output as it has only one comment that is 'ALL SMELL FLOWER', for a given group of tree, seed,flower and year
Tree KIWI should not be in output because only one comment available for a given group of tree, seed,flower and year
Tree PAPAYA should not be in output because FLRNO '81250' is not available with Bad Smell Flower
Tree Apple should not be in output because comment2 (God ) is not available with comment1 (SE; Bad SMELL FLOWER)
These all are treated as only one type of flower as 'ALL SMELL FLOWER' i need to check %smell flower% excluding
value before and after semicolon (;)
'SXT; ALL SMELL FLOWER'
'SE; ALL SMELL FLOWER;TX'
'TD;ALL SMELL FLOWER'
*/
create table #temp ( TREE varchar (500), SEED varchar (500), FLOWER varchar (500), Year varchar (500), FLRNO varchar (500), COMMENT1 varchar (500), COMMENT3 varchar (500), hash AS hashbytes('MD5', [TREE] + SEED + FLOWER + YEAR + FLRNO + COMMENT1 + COMMENT3) ) insert #temp SELECT 'BANANA', 'Nis', 'Tit', '2004', '57101', 'Sweet Smell Flower', '' UNION ALL SELECT 'BANANA', 'Nis', 'Tit', '2004', '57101', 'Bad Smell flower' , '' UNION ALL SELECT 'BANANA', 'Nis', 'Tit', '2004', 'B0019B', 'Sweet Smell Flower', 'CATCH ME' UNION ALL SELECT 'BANANA', 'Nis', 'Tit', '2004', 'B0019B', 'Bad Smell flower', 'CATCH ME' UNION ALL SELECT 'MANGO', 'Dod', 'char', '2012', 'D935', 'SXT; ALL SMELL FLOWER','' UNION ALL SELECT 'MANGO', 'Dod', 'char', '2012', 'D935', 'SE; ALL SMELL FLOWER;TX', '' UNION ALL SELECT 'MANGO', 'Dod', 'char', '2012', 'D935', 'TD;ALL SMELL FLOWER', '' UNION ALL SELECT 'KIWI', 'TOY', 'TAC', '2004', 'S205', 'W/T; Sweet Smell Flower','' UNION ALL SELECT 'PAPAYA', 'LIK', 'VIM', '1976', '13122', 'Sweet Smell Flower','' UNION ALL SELECT 'PAPAYA', 'LIK', 'VIM', '1976', '13122', 'Bad Smell flower','' UNION ALL SELECT 'PAPAYA', 'LIK', 'VIM', '1976', '81250', 'Sweet Smell Flower','' UNION ALL SELECT 'PAPAYA', 'LIK', 'VIM', '1976', '81250', 'Sweet Smell Flower','' UNION ALL SELECT 'APPLE', 'ALE', 'PPL', '2015', 'PRS13', 'SXT; SWEET SMELL FLOWER', 'God' UNION ALL SELECT 'APPLE', 'ALE', 'PPL', '2015', 'PRS13', 'SE; Bad SMELL FLOWER', 'CATCH ME' UNION ALL SELECT 'APPLE', 'ALE', 'PPL', '2015', 'PRS13', 'SXT; SWEET SMELL FLOWER', 'CATCH ME' Expected Output 'BANANA', 'Nis', 'Tit', '2004', '57101', 'Sweet Smell Flower', '' 'BANANA', 'Nis', 'Tit', '2004', '57101', 'Bad Smell flower' , '' 'BANANA', 'Nis', 'Tit', '2004', 'B0019B', 'Sweet Smell Flower', 'CATCH ME' 'BANANA', 'Nis', 'Tit', '2004', 'B0019B', 'Bad Smell flower', 'CATCH ME'
Thanks a ton.