Click here to Skip to main content
15,910,886 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
customer table

promotion_id customer_name cust_level_id customer_key
40286143 0000010966 - SPAR SOUTH RAND 53 5536
40287023 0000120004 - Pick 'n Pay Supermarkets 54 1719
40290119 0000120052 - Pick 'n Pay Hypermarkets 55 1699
40287672 0000140011 - Spar Lowveld DC 56 3958
hrycy_customer table

customer_key customer_parent_key
5536 1710
1719 1745
1699 3941
3958 4090
7 3656


if cust_level_id is 54 then it will have to get the customer_parent_key of customer_key
if cust_level_id is 55 then we he have to find customer_parent_key in 54 lavelfrom then for that find customer_paren_key in 53 level.
if cust_level_id is 55 then traverse through 55 and 54 level then get corresponding Customer_parent_key from 53 level.
Posted
Comments
_Asif_ 26-Jun-14 7:17am    
Check Common Table Expression and hierarchical Queries in SQL Server

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900