我試圖衡量一些銷售數據隨時間的增長。我組的電流和以前一起銷售基於最後N個月,得到以下(略)表:基於其他列值劃分列值
+-------------------------------+---------------+-------------+
| CUSTOMER_NAME | TIMEFRAME | GROSS_SALES |
+-------------------------------+---------------+-------------+
| SALLY'S SALES INC | CURRENT | 1207.76 |
| SALLY'S SALES INC | PREVIOUS | 8139.49 |
| DAVES PRODUCTS LLC | CURRENT | 909.92 |
| DAVES PRODUCTS LLC | PREVIOUS | 2867.41 |
| MEGACORP | CURRENT | 8369.05 |
| MEGACORP | PREVIOUS | 19123.75 |
+-------------------------------+---------------+-------------+
我試圖計算當前和以前的銷售之間的商,像
+-------------------------------+----------------+
| CUSTOMER_NAME | SALES_FACTOR |
+-------------------------------+----------------+
| SALLY'S SALES INC | 0.148382761082 |
| DAVES PRODUCTS LLC | 0.317331668649 |
| MEGACORP | 0.690302092999 |
+-------------------------------+----------------+
但是,我無法弄清楚正確地將每個客戶名稱的兩個值分開的查詢。
完美 - 謝謝! –