I am trying to update a table and use a subquery for the argument. I think I have both queries correct but since but since they are from two tables I am not tying together correctly. Can you tell me what I need to do?
update MVXJDTA.MITMAS set MMSTAT ='01' where MVXJDTA.MITMAS.MMITNO = MVXJDTA.MITSTA.MHITNO (Select MHITNO as Item, SUM(MHMAQT+MHPUQT + MHSOQT + MHUSQT + MHDEMQ)as total from MVXJDTA.MITSTA where MHCYP6 Between 200801 and 201102 Group by MHITNO Having SUM(MHMAQT+MHPUQT + MHSOQT + MHUSQT + MHDEMQ) <= 0)
Software/Hardware used:
winSql
ASKED:
February 17, 2011 8:04 PM
UPDATED:
February 18, 2011 11:19 PM
What database product are you using ?
Also, could you please explain what you are trying to accomplish (with words) ?
Maybe something like this is what you are looking for:
Or this (this syntax may not work in all databases):
Carlos,
I have not had a chance to try but the goal is to pull history information on parts (MMITNO or MHITNO) and if no usage in the past 2 years (or some time frame) then change the status (MMSTST) to 01.
We are on MS SQL 2005
Carlos,
After trying the First option,,, It worked. Thanks for your help.
I thought I’d have to connect the items prior to the sub query but i did not.
Thanks again.
Great.
You are welcome.
Different options could produce different response times. If this is going to be run regularly, it would be a good idea to look for the most efficient alternative.