Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I tested the SQL(T-SQL in SQL Server) below. It returns 11.5876 as grand_total. Is this okay for you?</p> <pre><code>create table #raw_financials ( title varchar(20) ,partner_share_currency varchar(20) ,us_earnings_usd decimal(15, 5) ,cad_earnings_cad decimal(15, 5) ,date datetime ) insert into #raw_financials values ('Gamers', 'USD', 3.25, 0, '2012-12-01') insert into #raw_financials values ('Gamers', 'CAD', 0, 4, '2012-12-01') insert into #raw_financials values ('Gamers', 'USD', 4.5, 0, '2012-12-01') create table #exchange_rates ( currency varchar(20) ,conversion_to_usd decimal(15, 5) ,date datetime ) insert into #exchange_rates values ('CAD', 0.95940, '2012-12-01') insert into #exchange_rates values ('USD', 1, '2012-12-01') SELECT rf.title, --partner_share_currency, SUM((rf.us_earnings_usd + rf.cad_earnings_cad) * er.conversion_to_usd) AS grand_total FROM #raw_financials rf INNER JOIN #exchange_rates er ON er.currency = rf.partner_share_currency AND er.date = rf.date WHERE rf.title LIKE '%Gamers%' AND rf.date='2012-12-01' GROUP BY rf.title </code></pre> <p>But I have never used MySQL, so the result might be different.</p> <p><strong>Update:</strong> Here is another query for GBP and SEK. It returns 14.81396 in my T-SQL:</p> <pre><code>create table #raw_financials ( title varchar(20) ,partner_share_currency varchar(20) ,us_earnings_usd decimal(15, 5) ,cad_earnings_cad decimal(15, 5) ,uk_earnings_gbp decimal(15, 5) ,swedish_earnings_skk decimal(15, 5) ,date datetime ) insert into #raw_financials values ('Gamers', 'USD', 3.25, 0, 0, 0, '2012-12-01') insert into #raw_financials values ('Gamers', 'CAD', 0, 4, 0, 0, '2012-12-01') insert into #raw_financials values ('Gamers', 'USD', 4.5, 0, 0, 0, '2012-12-01') insert into #raw_financials values ('Gamers', 'GBP', 0, 0, 2, 0, '2012-12-01') insert into #raw_financials values ('Gamers', 'SEK', 0, 0, 0, 1, '2012-12-01') create table #exchange_rates ( currency varchar(20) ,conversion_to_usd decimal(15, 5) ,date datetime ) insert into #exchange_rates values ('CAD', 0.95940, '2012-12-01') insert into #exchange_rates values ('USD', 1, '2012-12-01') insert into #exchange_rates values ('GBP', 1.54223, '2012-12-01') insert into #exchange_rates values ('SEK', 0.14190, '2012-12-01') SELECT rf.title, SUM((rf.us_earnings_usd + rf.cad_earnings_cad + rf.uk_earnings_gbp + rf.swedish_earnings_skk ) * er.conversion_to_usd) AS grand_total FROM #raw_financials rf INNER JOIN #exchange_rates er ON er.currency = rf.partner_share_currency AND er.date = rf.date WHERE rf.title LIKE '%Gamers%' AND rf.date='2012-12-01' GROUP BY rf.title </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload