-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiangwei1995910
committed
Jul 8, 2019
1 parent
aaa50e9
commit 62b9138
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 房价均价查询语句 | ||
|
||
db.lianjia.aggregate([ | ||
{'$match': {"address.0": {$exists: true}}}, | ||
{ | ||
$group: { | ||
_id: {"$arrayElemAt": ["$address", 0]}, | ||
count: {$sum: 1}, | ||
avg_UnitPrice: {$avg: "$UnitPrice"}, | ||
std: {$stdDevPop: "$UnitPrice"}, | ||
} | ||
}, | ||
{ | ||
$project: | ||
{ | ||
count: 1, //总数 | ||
avg_UnitPrice: 1, //每平米均价 | ||
std: 1, //标准差 | ||
ratio: {$divide: ["$std", "$avg_UnitPrice"]} //标准差与均价的比值 | ||
} | ||
}, | ||
{ | ||
'$sort': {count: -1} | ||
} | ||
]); | ||
|
||
|
||
// 平均薪资查询语句 | ||
|
||
db.zhilian.aggregate([ | ||
{'$match': {"workingExp.name": "1-3年"}}, | ||
{ | ||
$group: { | ||
_id: {"$arrayElemAt": ["$city.items", 0]}, | ||
count: {$sum: 1}, | ||
avg: {$avg: "$avg"}, | ||
std: {$stdDevPop: "$avg"}, | ||
} | ||
}, | ||
{ | ||
$project: | ||
{ | ||
count: 1, //总数 | ||
avg: 1, //平均薪资 | ||
std: 1, //标准差 | ||
ratio: {$divide: ["$std", "$avg"]} //标准差与均价的比值 | ||
} | ||
}, | ||
{ | ||
'$sort': {count: -1} | ||
} | ||
]); |