1
我想創建一個新的記錄類型列和非記錄類型列表。 該表將由查詢填充。創建一個表與記錄類型列
這是查詢:
select country, Count(*) CNT_Events,item,currency,sum(amount) as SUM_amount, count(transactionID) as CNT_transactionID
from
(select "US" country, "USD" currency, "book" item, 20 amount, 1 transactionID),
(select "Spain" Country,"EUR" currency, "book" item, 10 amount, 2 transactionID),
(select "US" Country,"USD" currency, "cup" item, 5 amount, 3 transactionID),
(select "Spain" Country,"EUR" currency, "notebook" item, 15 amount, 4 transactionID),
(select "Spain" Country,"EUR" currency, "notebook" item, 13 amount, 5 transactionID),
(select "US" Country, "null" currency, "null" item, null amount, null transactionID)
GROUP BY country, item, currency
模式:
[
{'name': 'country', 'type': 'STRING'},
{'name': 'CNT_Events', 'type': 'INTEGER'},
{'name': 'Purchases', 'type': 'RECORD',
'mode': 'REPEATED',
'fields': [
{'name': 'item', 'type': 'STRING'},
{'name': 'currency', 'type': 'STRING'},
{'name': 'SUM_amount', 'type': 'integer'},
{'name': 'CNT_transactionID', 'type': 'integer'}
]
},
]
,結果:
Country CNT_Events Purchases.item Purchases.currency Purchases.SUM_amount Purchases.CNT_transactionID
US 3 cup USD 5 1 book USD 20 1
Spain 3 book EUR 10 1 notebook EUR 28 2
我該怎麼辦呢? 謝謝!
的感謝!這就是我一直在尋找的! –