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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update question 1

Status
Not open for further replies.

jcisco2

Programmer
Apr 13, 2004
102
US
I'm creating a temp table to hold various data from multiple tables. and I'm having a problem with one statement (see code section) in the v_PlannedProduction table it can hold the same item number twice with more than one start date. All i need to do is get the first instance of the start date for my temp table.

Code:
update temp_Cuts set ProductRunDate = (SELECT  StartDate, ItemNumber
FROM         v_PlannedProduction
where temp_Cuts.ItemNumber = v_PlannedProduction.ItemNumber
GROUP BY  ItemNumber, StartDate
)

cheers
 
When you update field from derived table you must return ONLY one field in it:
Code:
update temp_Cuts set ProductRunDate = 
                     (SELECT  MIN(StartDate)
                              FROM v_PlannedProduction
                              where v_PlannedProduction.ItemNumber = temp_Cuts.ItemNumber)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top