SQL获得百分比(SQL getting Percentage)
我有以下代码来计算总死亡率和按PersonType分组。 现在我想要一个列来计算每个死亡事故的百分比。 这是为每个人的类型取值并除以总死亡人数。
Select distinct persontype as PerSsonType, sum(fatalities_in_crash) as Total_Deaths from [CarCrash].[Source_Data_Staging] group by PersonType
I have the following code to calculate total fatalities and group by the PersonType. Now I want to have a column that calculates the percentage of each fatalities. that is taking the value for each person type and dividing by the total fatalities.
Select distinct persontype as PerSsonType, sum(fatalities_in_crash) as Total_Deaths from [CarCrash].[Source_Data_Staging] group by PersonType
原文:https://stackoverflow.com/questions/47239068
最满意答案
当我尝试上传不属于批处理的单个文档时,我收到的错误与您相同:
{ "type": "delete", "id": "4e41b5a6f3d94aa4891ab8f9abca94e6" }
但如果它是批次的一部分,它会成功:
[{ "type": "delete", "id": "4e41b5a6f3d94aa4891ab8f9abca94e6" }]
我意识到你在上面的例子中显示了一个json数组,但值得仔细检查,因为当你试图发布一个不属于数组的单个文档时,你会得到完全相同的错误。 由于他们自己的准备提交数据的文档显示了删除不是数组的一部分的部分示例(请参阅“从搜索域中删除文档”部分),这将是一个容易犯的错误。
I get the same error as you when I try to upload a single document that is not part of a batch:
{ "type": "delete", "id": "4e41b5a6f3d94aa4891ab8f9abca94e6" }
But it succeeds if it's part of a batch:
[{ "type": "delete", "id": "4e41b5a6f3d94aa4891ab8f9abca94e6" }]
I realize that you show a json array in your example above, but it is worth double-checking since you're getting the exact same error you'd get when trying to post a single document that is not part of an array. It would be an easy mistake to make since their own documentation on preparing data for submission shows a partial example where the delete is not part of an array (see the "To delete a document from a search domain" section).
相关问答
更多-
当我尝试上传不属于批处理的单个文档时,我收到的错误与您相同: { "type": "delete", "id": "4e41b5a6f3d94aa4891ab8f9abca94e6" } 但如果它是批次的一部分,它会成功: [{ "type": "delete", "id": "4e41b5a6f3d94aa4891ab8f9abca94e6" }] 我意识到你在上面的例子中显示了一个json数组,但值得仔细检查,因为当你试图发布一个不属于数组的单个文档时,你会得到完全相 ...
-
Amazon Elasticsearch Service提供了Elasticsearch和Kibana的完全托管实施。 它通常用于日志文件的近实时可视化(但可以处理许多使用情况)。 Amazon CloudSearch基于Apache Solr。 它要求将数据作为文档加载,并且对于全文搜索有好处,并且对语言和语法(例如,同义词,要忽略的词)有所了解。 所以,真正归结为您是否想要使用Elasticsearch或Solr。 Amazon Elasticsearch Service provides a full ...
-
目前,AWS CloudSearch内部不支持此类搜索 Currently there is no support for this kind of search inside AWS CloudSearch
-
在cloudsearch中,无法在半径范围内搜索Latlons。 您可以按距离订购,但您可以在半径内搜索。 由于您希望半径范围内的所有结果。 而是创建一个矩形,使其四边接触要搜索的圆。现在,您可以在边界框矩形内搜索并返回按距离排序的结果。 缺点是在边界框的角落会有一些结果,所以它们不在圆圈中,但它们会出现在cloudsearch结果中。 您可以使用它们以及近似值或根据距离进一步过滤。 这是一个相同的示例查询:q = user *&fq = location%3A%5B%2740.628611,-100.69 ...
-
如果您忽略该消息并上传文档,会发生什么? 我想您可以使用搜索字段进行搜索:review_rating_i What happens if you just ignore the message and Upload Documents? I think you may be able to search with Search Fields: review_rating_i
-
不,它不支持'成千上万'。 问题是查询是GET请求,服务器对URL的长度有限制。 对于CloudSearch,该限制似乎是5532个字符; 超越它,你会得到HTTP状态码413 FULL HEAD的错误。 我通过向CloudSearch发出请求来确定实验,我在其中更改了查询字符串的长度; 我在任何地方都没有在他们的文档中看到它。 No, it does not support 'thousands and thousands'. The issue is that queries are GET reque ...
-
Amazon CloudSearch在文档上传时抛出HTTP 403(Amazon CloudSearch throws HTTP 403 on document upload)[2023-08-27]
如果您收到以下错误 403禁止通过管理规则禁止请求。 如果你确定你有适当的规则,我会检查你正在使用的API网址。 确保你使用的是正确的端点。 如果您正在进行批量上传,则api端点应如下所示 您的搜索-doc的端点/ 2013-01-01 /文件/批 注意2013-01-01,这是url的必需部分。 这是您将使用的api版本。 即使它有意义,你也不能做到以下几点 your-search-doc-endpoint / documents / batch < - 不起作用 要搜索您需要点击以下api 您的搜索端点 ... -
如何在AWS CloudSearch结构化查询中压缩条件?(How to condense not conditions in AWS CloudSearch structured query?)[2023-06-23]
通过De Morgan的定理 ,你可以重写 (and (not sc:1) (not sc:4) (not sc:9) (not sc:13) (not sc:14)) 如 (not (or sc:1 sc:4 sc:9 sc:13 sc:14)) 我认为这并不完全是你所希望的,因为它重复了sc: term,但有点简单 By De Morgan's Theorem, you can rewrite (and (not sc:1) (not sc:4) (not sc:9) (not sc:13) (not ... -
尼基尔就在那里。 在您的数据为CRUD的代码中,您将类似的调用添加到cloudsearch,但这两个语句都需要包含在事务上下文中。 这基本上确保了如果一个失败,它们都会失败。 没有这个,你永远无法保证同步。 Spring和Rails等框架提供了此功能,但您尚未说明您正在使用的内容。 Nikhil is halfway there. In the code where your data is CRUD'd you add the analogous calls to cloudsearch, but bot ...
-
我找到了回答我自己的问题。 “CloudSearchDomain”位于与“CloudSearch”分开的另一部分中。 我觉得很傻 http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudSearchDomain.html I found answer to my own question. "CloudSearchDomain" is in another section separated from "CloudSearch". i feel ...