Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 January 26th, 2005, 10:08 AM
Registered User
Join Date: Jan 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default procedure in SQL

I have a table that keeps exchange rates for multiple currencies:
fromCur, toCur, rate, effectiveDate
USD BRL .1 12/2/04
USD BRL .11 1/1/05
USD CAN .5 11/3/04 ...
and so on for all combinations.
I need to get the most recent rate for a given fromCur, for _EACH_ toCur and I can't think of a way to do it with out a procedural approach that:
1. Gets all ToCur's for a given fromCur (usd)
2. For each toCur, select top 1 rate from <table> where fromCur = 'usd' and toCur = @toCur order by effDate Desc

IS there a t-SQL only way to do this?
Thank you for any input.
Reply With Quote
  #2 (permalink)  
Old January 26th, 2005, 10:44 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post

croos-post, see http://p2p.wrox.com/topic.asp?TOPIC_ID=25561
Reply With Quote

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
Can't See SQL tables and Stored Procedure azambee SQL Server 2000 1 October 24th, 2008 01:03 PM
SQL Procedure problem Lofa SQL Server 2000 2 September 19th, 2005 12:36 PM
PL/SQL Procedure madhav007 Oracle 1 May 29th, 2005 01:22 AM
SQL Server Stored Procedure doug SQL Server 2000 2 February 22nd, 2005 03:04 PM
SQL Stored Procedure... babloo81 SQL Server ASP 1 December 8th, 2003 03:38 PM

All times are GMT -4. The time now is 05:30 AM.

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