我有一个表,其中一列中包含证券公司,另一列中包含母公司的ID,最后一列中包含该证券公司的市场价值。 我试图通过将具有相同父代ID的证券公司的市值加在一起来计算母公司的市值,我该如何实现?
该表称为安全性,我希望新列称为ParentSecMktValue。
我尝试使用SELECT语句:
SELECT security.Parent_id, security.SecMktValue
FROM security
ORDER BY Parent_id ASC;
这会生成一张有关父代ID及其市场价值的表格,但我不确定如何合并来自不同行的数据。
答案 0 :(得分:0)
您可以通过在parent_id上使用group by并在市场价值上使用sum函数来获取总和
import json
import scrapy
class PlasticsurgerySpider(scrapy.Spider):
name = 'plasticsurgery'
post_url = "https://find.plasticsurgery.org/default.aspx/GetMemberInfo"
headers = {"content-type": "application/json; charset=UTF-8"}
start_urls = ["https://find.plasticsurgery.org/city/new-york"]
def parse(self, response):
items = set([item.split("('")[1].split("')")[0] for item in response.css("a[onclick^='showMemberInfo']::attr(onclick)").getall()])
for item in items:
payload = {'memberId':item,'searchId':'38066000'}
yield scrapy.Request(url=self.post_url,headers=self.headers,callback=self.parse_page, method="POST", body=json.dumps(payload))
def parse_page(self,response):
data = json.loads(response.body_as_unicode())
for item in data:
name = data[item]['MemberName'].strip()
email = data[item]['Email']
yield {"name":name,"email":email}
答案 1 :(得分:0)
+ npm install
npm info it worked if it ends with ok
npm info using npm@3.10.10
npm info using node@v6.16.0
.
.
.
[lots of packages successfully installed]
.
.
npm http 200 https://registry.npmjs.org/inputmask
npm info retry fetch attempt 1 at 5:16:09 PM
npm info attempt registry request try #1 at 5:16:09 PM
npm http fetch GET https://registry.npmjs.org/inputmask/-/inputmask-3.3.11.tgz
npm http fetch 200 https://registry.npmjs.org/inputmask/-/inputmask-3.3.11.tgz
npm ERR! Linux 4.19.43-coreos
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v6.16.0
npm ERR! npm v3.10.10
npm ERR! code ENOGIT