Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Display One CompanyCode values instead of other companycode values

$
0
0
Hi,

I got stuck at one scenario. The requirement is, I have CompanyCode, ItemNumber and PlannerNumbers in a table and the values are shown below,
CompanyCode ItemCode            PlannerCode
10                    15066-00266-01  10053357
96                    15066-00266-01  10048778
10                    19200-00027-06  10052915
96                    19200-00027-06   0

I should i always display companycode 96 planners information. If there is no plannercode for an item then check if there is any plannercode for company 10 for the same item, if planner exists then display company 10 planner to company 96.

In the above example 19200-00027-06 item does not contain plannercode for company 96, then we display its companycode 10 planner for this item.. finally want the result set like

CompanyCode  ItemCode             PlannerCode
96                     15066-00266-01   10048778
96                     19200-00027-06 10052915

Could some one tell me how can write an sql statement for this requirement?

Any help would be greatly appreciated.

Thanks,
Venu.

Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>