Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.76 KB | None | 0 0
  1. SELECT ask_name as 'Âàëþòà',  ISNULL([AUD], 1) as 'AUD',
  2.     ISNULL([CAD], 1) as 'CAD',  ISNULL([CHF], 1) as 'CHF',  ISNULL([DKK], 1) as 'DKK',
  3.     ISNULL([EUR], 1) as 'EUR',  ISNULL([GBP], 1) as 'GBP',  ISNULL([JPY], 1) as 'JPY',
  4.     ISNULL([NZD], 1) as 'NZD',  ISNULL([SEK], 1) as 'SEK',  ISNULL([USD], 1) as 'USD'
  5. FROM
  6.     (SELECT DISTINCT cn_ask.name as [ask_name], cn_bid.name as [bid_name], exchange_rate FROM
  7.         (SELECT ask_currency_id, bid_currency_id, exchange_rate FROM dbo.ExchangeRates) as er
  8.         JOIN CurrencyNames as cn_ask
  9.         ON cn_ask.id = er.ask_currency_id
  10.         JOIN CurrencyNames as cn_bid
  11.         ON cn_bid.id = er.bid_currency_id) as cross_rates
  12.     PIVOT (
  13.         SUM(exchange_rate)
  14.         FOR bid_name IN ([AUD], [CAD], [CHF], [DKK], [EUR], [GBP], [JPY], [NZD], [SEK], [USD])
  15.     ) as pvt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement