Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 23rd, 2005, 04:12 AM
Authorized User
 
Join Date: Jun 2004
Location: York, East Yorkshire, United Kingdom.
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
  #2 (permalink)  
Old July 24th, 2005, 01:00 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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 )

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:57 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.