[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

I have conditions on joining tables, how do I implement this?

Asked by AshaRRichardson in MS SQL Server

Here is my problem.  I have the need for a conditional join.  I have a situation where proj_id and prop_item_key need to be joined between two tables:  DELTEK.TMP_PO_AVG_CST_PROJ    and DELTEK.TMP_PO_AVG_CST.  Problem is sometimes the proj_id will be null.  According to the rules of  NULL this can't be done because you can't compare NULL.  So when it is trying to join based on a null value, it gives me incorrect results.  

I was thinking of how I would get around this, I would run two different queries (same queries different joins based on proj_id being nULL or not null.

I don't know how to implement something like this.  I appreaciate any assitance from the experts.  If you need more info, just let me know what you need.

I hope this makes sense.  I could be going about this the wrong way.

Thanks ahead of time.
_____________________________________________________________________________________________________


If proj_id is null then


Select   CST_SRCE_TYPE_CD, TPLN.PROP_ITEM_KEY, AVGCST, TPLN.CST_SRCE_DT,  TPLN.PROJ_ID,    
MAX(CST_SRCE_ID) AS CST_SRCE_ID,
MAX(CST_SRCE_RLSE_NO) AS CST_SRCE_RLSE_NO,
MAX(CST_SRCE_LN_KEY) AS CST_SRCE_LN_KEY,    
MAX(CST_SRCE_LN_NO) AS CST_SRCE_LN_NO
                 
   
INTO     DELTEK.TMP_PO_AVG_CST_PROJ    
   
   
          from DELTEK.TMP_PO_LN as TPLN    
          LEFT OUTER JOIN DELTEK.TMP_PO_AVG_CST as TAC    
             ON TPLN.PROP_ITEM_KEY = TAC.PROP_ITEM_KEY
                   
 WHERE  CST_SRCE_DT = (SELECT MAX(CST_SRCE_DT) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
     AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)

AND CST_SRCE_ID  = (SELECT MAX(CST_SRCE_ID) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
    AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)

AND CST_SRCE_RLSE_NO  = (SELECT MAX(CST_SRCE_RLSE_NO) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
     AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)

AND CST_SRCE_LN_KEY  = (SELECT MAX(CST_SRCE_LN_KEY) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
     AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)

AND CST_SRCE_LN_NO  = (SELECT MAX(CST_SRCE_LN_NO) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
     AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)
   
GROUP BY  CST_SRCE_TYPE_CD, TPLN.PROP_ITEM_KEY, AVGCST, TPLN.CST_SRCE_DT,  TPLN.PROJ_ID
ORDER BY  TPLN.PROJ_ID, CST_SRCE_TYPE_CD,  TPLN.PROP_ITEM_KEY, AVGCST

else

Select   CST_SRCE_TYPE_CD, TPLN.PROP_ITEM_KEY, AVGCST, TPLN.CST_SRCE_DT,  TPLN.PROJ_ID,    
MAX(CST_SRCE_ID) AS CST_SRCE_ID,
MAX(CST_SRCE_RLSE_NO) AS CST_SRCE_RLSE_NO,
MAX(CST_SRCE_LN_KEY) AS CST_SRCE_LN_KEY,    
MAX(CST_SRCE_LN_NO) AS CST_SRCE_LN_NO
                 
   
INTO     DELTEK.TMP_PO_AVG_CST_PROJ    
   
   
          from DELTEK.TMP_PO_LN as TPLN    
          LEFT OUTER JOIN DELTEK.TMP_PO_AVG_CST as TAC    
             ON TPLN.PROP_ITEM_KEY = TAC.PROP_ITEM_KEY
 AND  
         TPLN.PROJ_ID = TAC.PROJ_ID  
                   
 WHERE  CST_SRCE_DT = (SELECT MAX(CST_SRCE_DT) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
     AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)

AND CST_SRCE_ID  = (SELECT MAX(CST_SRCE_ID) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
    AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)

AND CST_SRCE_RLSE_NO  = (SELECT MAX(CST_SRCE_RLSE_NO) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
     AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)

AND CST_SRCE_LN_KEY  = (SELECT MAX(CST_SRCE_LN_KEY) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
     AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)

AND CST_SRCE_LN_NO  = (SELECT MAX(CST_SRCE_LN_NO) FROM DELTEK.TMP_PO_LN TPOLN WHERE TPOLN.CST_SRCE_DT = TPLN.CST_SRCE_DT
     AND TPOLN.PROP_ITEM_KEY = TPLN.PROP_ITEM_KEY)
   
GROUP BY  CST_SRCE_TYPE_CD, TPLN.PROP_ITEM_KEY, AVGCST, TPLN.CST_SRCE_DT,  TPLN.PROJ_ID
ORDER BY  TPLN.PROJ_ID, CST_SRCE_TYPE_CD,  TPLN.PROP_ITEM_KEY, AVGCST
[+][-]11/24/04 11:14 AM, ID: 12668855Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: MS SQL Server
Sign Up Now!
Solution Provided By: boblah
Participating Experts: 3
Solution Grade: A
 
[+][-]11/24/04 11:44 AM, ID: 12669139Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/24/04 11:49 AM, ID: 12669178Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/24/04 11:51 AM, ID: 12669205Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/24/04 12:21 PM, ID: 12669434Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/24/04 12:21 PM, ID: 12669437Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/24/04 12:32 PM, ID: 12669531Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/24/04 12:36 PM, ID: 12669563Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/24/04 12:37 PM, ID: 12669573Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/24/04 12:40 PM, ID: 12669590Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89