Database: debit_card_specializing

Question: Which of the three segments—SME, LAM and KAM—has the biggest and lowest percentage increases in consumption paid in EUR between 2012 and 2013?
Evidence: Increase or Decrease = consumption for 2013 - consumption for 2012; Percentage of Increase = (Increase or Decrease / consumption for 2013) * 100%; The first 4 strings of the Date values in the yearmonth table can represent year
SQL (SQLite): SELECT CAST((SUM(IIF(T1.Segment = 'SME' AND T2.Date LIKE '2013%', T2.Consumption, 0)) - SUM(IIF(T1.Segment = 'SME' AND T2.Date LIKE '2012%', T2.Consumption, 0))) AS FLOAT) * 100 / SUM(IIF(T1.Segment = 'SME' AND T2.Date LIKE '2012%', T2.Consumption, 0)), CAST(SUM(IIF(T1.Segment = 'LAM' AND T2.Date LIKE '2013%', T2.Consumption, 0)) - SUM(IIF(T1.Segment = 'LAM' AND T2.Date LIKE '2012%', T2.Consumption, 0)) AS FLOAT) * 100 / SUM(IIF(T1.Segment = 'LAM' AND T2.Date LIKE '2012%', T2.Consumption, 0)) , CAST(SUM(IIF(T1.Segment = 'KAM' AND T2.Date LIKE '2013%', T2.Consumption, 0)) - SUM(IIF(T1.Segment = 'KAM' AND T2.Date LIKE '2012%', T2.Consumption, 0)) AS FLOAT) * 100 / SUM(IIF(T1.Segment = 'KAM' AND T2.Date LIKE '2012%', T2.Consumption, 0)) FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID
SQL (SQL Server): SELECT TRY_CAST((SUM(IIF(T1.Segment = 'SME' AND T2.Date LIKE '2013%', TRY_CAST(T2.Consumption AS FLOAT), 0.0)) - SUM(IIF(T1.Segment = 'SME' AND T2.Date LIKE '2012%', TRY_CAST(T2.Consumption AS FLOAT), 0.0))) AS FLOAT) * 100 / SUM(IIF(T1.Segment = 'SME' AND T2.Date LIKE '2012%', TRY_CAST(T2.Consumption AS FLOAT), 0.0)), TRY_CAST(SUM(IIF(T1.Segment = 'LAM' AND T2.Date LIKE '2013%', TRY_CAST(T2.Consumption AS FLOAT), 0.0)) - SUM(IIF(T1.Segment = 'LAM' AND T2.Date LIKE '2012%', TRY_CAST(T2.Consumption AS FLOAT), 0.0)) AS FLOAT) * 100 / SUM(IIF(T1.Segment = 'LAM' AND T2.Date LIKE '2012%', TRY_CAST(T2.Consumption AS FLOAT), 0.0)), TRY_CAST(SUM(IIF(T1.Segment = 'KAM' AND T2.Date LIKE '2013%', TRY_CAST(T2.Consumption AS FLOAT), 0.0)) - SUM(IIF(T1.Segment = 'KAM' AND T2.Date LIKE '2012%', TRY_CAST(T2.Consumption AS FLOAT), 0.0)) AS FLOAT) * 100 / SUM(IIF(T1.Segment = 'KAM' AND T2.Date LIKE '2012%', TRY_CAST(T2.Consumption AS FLOAT), 0.0)) AS _agg1 FROM customers AS T1 INNER JOIN yearmonth AS T2 ON T1.CustomerID = T2.CustomerID
SQL (Oracle): SELECT CAST((SUM(CASE WHEN T1.Segment = 'SME' AND T2."DATE" LIKE '2013%' THEN CAST(T2.Consumption AS BINARY_DOUBLE) ELSE 0.0 END) - SUM(CASE WHEN T1.Segment = 'SME' AND T2."DATE" LIKE '2012%' THEN CAST(T2.Consumption AS BINARY_DOUBLE) ELSE 0.0 END)) AS BINARY_DOUBLE) * 100 / SUM(CASE WHEN T1.Segment = 'SME' AND T2."DATE" LIKE '2012%' THEN CAST(T2.Consumption AS BINARY_DOUBLE) ELSE 0.0 END), CAST(SUM(CASE WHEN T1.Segment = 'LAM' AND T2."DATE" LIKE '2013%' THEN CAST(T2.Consumption AS BINARY_DOUBLE) ELSE 0.0 END) - SUM(CASE WHEN T1.Segment = 'LAM' AND T2."DATE" LIKE '2012%' THEN CAST(T2.Consumption AS BINARY_DOUBLE) ELSE 0.0 END) AS BINARY_DOUBLE) * 100 / SUM(CASE WHEN T1.Segment = 'LAM' AND T2."DATE" LIKE '2012%' THEN CAST(T2.Consumption AS BINARY_DOUBLE) ELSE 0.0 END), CAST(SUM(CASE WHEN T1.Segment = 'KAM' AND T2."DATE" LIKE '2013%' THEN CAST(T2.Consumption AS BINARY_DOUBLE) ELSE 0.0 END) - SUM(CASE WHEN T1.Segment = 'KAM' AND T2."DATE" LIKE '2012%' THEN CAST(T2.Consumption AS BINARY_DOUBLE) ELSE 0.0 END) AS BINARY_DOUBLE) * 100 / SUM(CASE WHEN T1.Segment = 'KAM' AND T2."DATE" LIKE '2012%' THEN CAST(T2.Consumption AS BINARY_DOUBLE) ELSE 0.0 END) FROM customers T1 INNER JOIN yearmonth T2 ON T1.CustomerID = T2.CustomerID