Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update SQL Help Needed

Status
Not open for further replies.

OAKEJ

Programmer
Apr 13, 2005
39
0
0
US
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
 
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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top