Skip to content

Instantly share code, notes, and snippets.

@glamp
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glamp/41069318da798b24ca7e to your computer and use it in GitHub Desktop.
Save glamp/41069318da798b24ca7e to your computer and use it in GitHub Desktop.
select
Country
, 'Real' as Currency
, 3.13 as ExchangeRate
, sum(Total*3.13) as LocalCurrencyTotal
from
Customer c
inner join
Invoice i
on
i.CustomerId = c.CustomerId
where
Country = 'Brazil'
and Total > 5
group by
Country
UNION ALL
select
Country
, 'Canadian Dollar' as Currency
, 1.27 as ExchangeRate
, sum(Total*1.27) as LocalCurrencyTotal
from
Customer c
inner join
Invoice i
on
i.CustomerId = c.CustomerId
where
Country = 'Canada'
and Total > 1.5
group by
Country
UNION ALL
select
Country
, 'Kourna' as Currency
, 25.45 as ExchangeRate
, sum(Total*25.45) as LocalCurrencyTotal
from
Customer c
inner join
Invoice i
on
i.CustomerId = c.CustomerId
where
Country = 'Czech Republic'
and Total > 10
group by
Country
UNION ALL
select
Country
, 'Euro' as Currency
, 0.93 as ExchangeRate
, sum(Total*0.93) as LocalCurrencyTotal
from
Customer c
inner join
Invoice i
on
i.CustomerId = c.CustomerId
where
Country = 'Austria'
and Total > 1
group by
Country
UNION ALL
select
Country
, 'Euro' as Currency
, 0.93 as ExchangeRate
, sum(Total*0.93) as LocalCurrencyTotal
from
Customer c
inner join
Invoice i
on
i.CustomerId = c.CustomerId
where
Country = 'Belgium'
and Total > 2
group by
Country
UNION ALL
select
Country
, 'Krone' as Currency
, 6.95 as ExchangeRate
, sum(Total*6.95) as LocalCurrencyTotal
from
Customer c
inner join
Invoice i
on
i.CustomerId = c.CustomerId
where
Country = 'Denmark'
and Total > 3
group by
Country
UNION ALL
select
Country
, 'US Dollar' as Currency
, 1.0 as ExchangeRate
, sum(Total*1.0) as LocalCurrencyTotal
from
Customer c
inner join
Invoice i
on
i.CustomerId = c.CustomerId
where
Country = 'USA'
and Total > 1.2
group by
Country
UNION ALL
select
Country
, 'Euro' as Currency
, 0.93 as ExchangeRate
, sum(Total*0.93) as LocalCurrencyTotal
from
Customer c
inner join
Invoice i
on
i.CustomerId = c.CustomerId
where
Country = 'France'
and Total > 2.3
group by
Country
UNION ALL
select
Country
, 'Euro' as Currency
, 0.93 as ExchangeRate
, sum(Total*0.93) as LocalCurrencyTotal
from
Customer c
inner join
Invoice i
on
i.CustomerId = c.CustomerId
where
Country = 'Germany'
and Total > 4.1
group by
Country
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment