1
我有這樣SQL創建基於內容
saledate | user_id | Purchase or Return | trans_amount
2016/4/1 | 001 | Purchase | 100
2016/4/1 | 001 | Return | 200
2016/4/2 | 002 | Purchase | 300
2016/4/2 | 003 | Purchase | 200
2016/4/2 | 004 | Return | 100
...
SQL表如何運行一個查詢,更改表,以便它看起來像這樣的新列:
saledate | transaction_type | number of unique user_ids | total_amount
2016/4/1 | Purchase only | 20 | 1000
2016/4/1 | Return only | 30 | 1000
2016/4/1 | Purchase_return | 40 | 2000
...
謝謝!
標籤與正在使用的數據庫你的問題。 –