diff --git a/2.4.cpp b/2.4.cpp index 4f59164..aaa00a0 100644 --- a/2.4.cpp +++ b/2.4.cpp @@ -64,6 +64,27 @@ int main() }); }); + conn.exec("use bigdata2",nullptr); + conn.exec("select job_city,count(*) from (select job_city from pages group by company_name) as B group by job_city", + [&](MySQLResult& res) + { + res.stepRow([&](char** val,unsigned long* len) + { + string city(val[0]); + int cnt=ParseInt(val[1]); + + auto iter=mp.find(city); + if(iter!=mp.end()) + { + iter->second += cnt; + } + else + { + mp.insert(make_pair(city,cnt)); + } + }); + }); + for(auto iter=mp.begin();iter!=mp.end(); ) { bool updated=false;