Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
|
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2005, 04:12 AM
Authorized User
 
Join Date: Jun 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default SELECT/ORDER/INSERT

Not sure how to approach this one and would really value some help. Essentually I have 12,000 products in a database table (tbl_product)each with a unique stock code. Then in table two I have the same again only with each of the stock codes repeated with multiple buy prices, I need to select the cheapest buy price from multiple and then insert into the tbl_product.

So thats: select cheapest price from EACH stock code. (tbl_buy), for example there could be 12 distributors for each product. 1 of those distributors offers the cheapest price, of which I want to update the coresponding stock code in the other tbl_product table.

Think that makes sense.... any help would be greatly received.

Stuart
 
Old July 24th, 2005, 01:00 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Update
   tbl_product
Set
   tbl_product.price = (Select MIN(price)
              From tbl_Buy b
              Where b.id = tbl_product.id
              Group By ID )






Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR 145: ORDER BY ITEMS... SELECT DISTINCT... tbaquero SQL Server 2000 7 May 8th, 2008 02:30 AM
Updating products quantity when order item insert Tawanda BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 June 7th, 2007 02:30 PM
Insert into & order by... kiwikencox SQL Server 2000 5 October 13th, 2005 05:06 AM
Select Distinct Order by... MichaelTJ SQL Language 2 November 17th, 2003 12:49 AM
SELECT and INSERT in wrong order sgarstin MySQL 0 October 16th, 2003 02:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.