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

SQL - Complex join - Cascading conditions

$
0
0

Hi all,

I've the following two tables - 

MasterData - 

Project_IDCategoryParent_ID
P1ANULL
P2ANULL
P3ANULL
P4AP1
P5AP1
P6ENULL
P7AP2
P8AP2
P9AP3
P10DP6

Project_Totals

Project_IDTotal
P1500
P2600
P6700
P10800

I need to join these two tables and get projects AND their child projects based on the condition Category = A.

Expected Results - 

Project_IDTotal
P1500
P2600
P4NULL
P5NULL
P7NULL
P8NULL

So the projects from Project_totals have to be first obtained with category 'A' condition and their corresponding child projects have to be fetched from Masterdata. I'm not able to construct the query to get the desired results. Can someone help me?


NLV - MCTS - Blog - Twitter - In



Viewing all articles
Browse latest Browse all 8428

Trending Articles



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