Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
yingchai
Starting Member
33 Posts |
Posted - 2011-06-06 : 02:24:21
|
| Hi, I need your expertise on this issue. Basically the reason to do this is to group the rates so that my BI tool can read the table correctly.For example, I have the following data:foreign_curr local_curr year period ytd_ave_rate closing_rate--------------------------MYR MYR 01 2011 1.0000 1.0000USD MYR 01 2011 0.3125 0.3030Based on the example above, I intend to get the following result set and save it in my Views. Noticed that the ytd_ave_rate and closing_rate column name becomes the values under exchange_rate column.foreign_curr local_curr year period exchange_rate rate_value--------------------------MYR MYR 01 2011 ytd_ave_rate 1.0000 MYR MYR 01 2011 closing_rate 1.0000USD MYR 01 2011 ytd_ave_rate 0.3125USD MYR 01 2011 closing_rate 0.3030Any help you can provide with be greatly appreciated. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-06-06 : 03:18:07
|
[code]SELECT foreign_curr, local_curr, year period, exchange_rate = 'ytd_ave_rate', ytd_ave_rate FROM yourtableUNION ALLSELECT foreign_curr, local_curr, year period, exchange_rate = 'closing_rate', closing_rate FROM yourtable[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|
|
|