我的JSON數據:DocumentDB得到子陣
[
{
"Code": "GB-00001",
"BasicInformation": {
"WGS84Longitude": -4.670000,
"WGS84Latitude": 50.340000
},
"Availability": [{
"ArrivalDate": "2017-04-21",
"Price": 689
},
{
"ArrivalDate": "2017-04-28",
"Price": 1341
}
]},
{
"Code": "GB-00002",
"BasicInformation": {
"WGS84Longitude": -4.680000,
"WGS84Latitude": 50.350000
},
"Availability": [{
"ArrivalDate": "2017-04-21",
"Price": 659
},
{
"ArrivalDate": "2017-04-28",
"Price": 1440
}
]}
}]
我希望得到的結果是這樣的:
[
{
"HouseCode": "GB-00001",
"Country": "GB",
"location": {
"type": "Point",
"coordinates": [
50.340000,
-4.670000
]
}, "lowestPrice": 689
},
{
"HouseCode": "GB-00002",
"Country": "GB",
"location": {
"type": "Point",
"coordinates": [
50.350000,
-4.680000
]
}, "lowestPrice" : 659
}
我的問題是:如何使用min(c.Availability.Price)
這是我目前的查詢,經緯度轉換爲點,但不知道如何獲得最低/最低價格。
SELECT c.Code, c.BasicInformation.Country ,
{"type":"Point","coordinates": [c.BasicInformation.Latitude, c.BasicInformation.Longitude]} as location
FROM c
已經嘗試過用Join c.Availability a
和, min(a.Price)
編輯也許是我太早了? https://feedback.azure.com/forums/263030-documentdb/suggestions/18561901-add-group-by-support-for-aggregate-functions 發現url https://stackoverflow.com/a/42697673/169714
所以我不能使用min(a.Price),因爲在使用聚合函數時缺乏分組並且需要創建用戶定義的函數?我以前從未使用過udf,所以我會仔細研究它,並會回到此處。謝謝您的回答。編輯:墜毀http://imgur.com/a/hxoJ9 –
屏幕截圖不是英文 –
它只是一個常規的Windows消息。 DocumentDB.GatewayService.exe已停止工作。等等。 –