×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Update SQL Help Needed

Update SQL Help Needed

Update SQL Help Needed

(OP)
I need to update File(OAKEJ/FLPJ) and Set PJPRMP(Primary Supplier) to "Y" when PJLCOS(Last Cost)= WP1COS(the Lowest Cost from OAKEJ/FLCP1WP for Part 'A 680 322 12 25'
as well as Set PJPRMP to "N" when PJLCOS>WP1COS

**************Initial SQL STATEMENT***************
SELECT PJSITE,PJSPAR,PJPRMP,PJLCOS,WP1COS        
FROM OAKEJ/FLPJ JOIN FLCP1WP ON PJSITE=WP1SIT AND
PJSPAR=WP1PRT      
WHERE PJSPAR='A 680 322 12 25'
ORDER BY PJSITE,PJSPAR                           

****************SQL RESULTS***************************
PJSITE  PJSPAR           PJPRMP UpdateTo  PJLCOS    WP1COS
MASTER  A 680 322 12 25    Y     (N)         13.91     13.77
MASTER  A 680 322 12 25    N     (Y)         13.77     13.77
MASTER  A 680 322 12 25    N     (Y)         13.77     13.77
MASTER  A 680 322 12 25    Y     (N)         13.91     13.77
MASTER  A 680 322 12 25    N     (Y)         13.77     13.77

Any Suggestions would be appreciated. Thanks in advance
       

RE: Update SQL Help Needed

(OP)
Nevermind I have it now.

SQL to change the Primary code to Y if it is the lowest cost............
UPDATE OAKEJ/FLPJ PJ                              
SET    PJPRMP = 'Y'                               
      ,PJCHGD = '1091113'                         
      ,PJCHGT = '1202'                            
      ,PJCHGU = 'OAKEJ'                           
      ,PJCHGP = 'SQL'                             
WHERE  PJ.PJLCOS IN(SELECT WP1COS              
                    FROM FLCP1WP               
                    WHERE AND PJ.PJSITE=WP1SIT
                          AND PJ.PJSPAR=WP1PRT
                          AND PJ.PJLCOS=WP1COS)   

The SQL that changes the Primary Code to N if it isn't the lowest cost............
UPDATE OAKEJ/FLPJ PJ                              
SET    PJPRMP = 'N'                               
      ,PJCHGD = '1091113'                         
      ,PJCHGT = '1202'                            
      ,PJCHGU = 'OAKEJ'                           
      ,PJCHGP = 'SQL'                             
WHERE  PJ.PJLCOS > (SELECT WP1COS                 
                    FROM FLCP1WP                  
                    WHERE PJ.PJSITE=WP1SIT          
                    AND   PJ.PJSPAR=WP1PRT)  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close