count

How to count and group query to get proper results?

喜夏-厌秋 提交于 2020-01-24 11:44:05
问题 I have a problem, please see my database: ------------------- | id | article_id | ------------------- | 1 | 1 | | 2 | 1 | | 3 | 1 | | 4 | 2 | | 5 | 2 | | 6 | 3 | | 7 | 3 | | 8 | 3 | | 9 | 3 | | 10 | 3 | And I want to receive something like this (order by votes, from max to min): --------------------------- | id | article_id | votes | --------------------------- | 1 | 3 | 5 | | 2 | 1 | 3 | | 3 | 2 | 2 | Could you please help me to write proper sql query? 回答1: SELECT article_id, COUNT(article

R - count all combinations

回眸只為那壹抹淺笑 提交于 2020-01-24 02:43:25
问题 I would like to count all combinations in a data.frame. The data look like this 9 10 11 12 1 1 1 1 1 2 0 0 0 0 3 0 0 0 0 4 1 1 1 1 5 1 1 1 1 6 0 0 0 0 7 1 0 0 1 8 1 0 0 1 9 1 1 1 1 10 1 1 1 1 The output I want is simply comb n 1 1 1 1 5 0 0 0 0 3 1 0 0 1 2 Do you know any simple function to do that ? Thanks dt = structure(list(`9` = c(1, 0, 0, 1, 1, 0, 1, 1, 1, 1), `10` = c(1, 0, 0, 1, 1, 0, 0, 0, 1, 1), `11` = c(1, 0, 0, 1, 1, 0, 0, 0, 1, 1), `12` = c(1, 0, 0, 1, 1, 0, 1, 1, 1, 1)), .Names =

Making a CountRows function in Excel

好久不见. 提交于 2020-01-24 00:48:26
问题 I am trying to make a simple countRows function that will count the number of cells I have in a dynamic range. Basically if I have values in cells, say B2:B500, the count would return 499. However next time around values are in cell B2:B501, the count would return 500. But you wouldn't have to do anything to the cell in which you typed in the formula. I thought if I reference the cell as a Variant , then any value could be accepted. Then find the Address of that cell and return the Count of a

How to count null values in postgresql?

a 夏天 提交于 2020-01-22 02:33:05
问题 select distinct "column" from table; output: column 1 0.0 2 [null] 3 1.0 But when I try to count the null values select count("column") from train where "column" is NULL; Gives output 0 (zero) Can you suggest where it's going wrong? 回答1: Use count(*) : select count(*) from train where "column" is NULL; count() with any other argument counts the non-NULL values, so there are none if "column" is NULL . 来源: https://stackoverflow.com/questions/53934294/how-to-count-null-values-in-postgresql

Powershell counting same values from csv

巧了我就是萌 提交于 2020-01-22 02:26:08
问题 Using PowerShell, I can import the CSV file and count how many objects are equal to "a". For example, @(Import-csv location | where-Object{$_.id -eq "a"}).Count Is there a way to go through every column and row looking for the same String "a" and adding onto count? Or do I have to do the same command over and over for every column, just with a different keyword? 回答1: Try cycling through properties like this: (Import-Csv location | %{$record = $_; $record | Get-Member -MemberType Properties |

Count items by condition with XML and PHP?

夙愿已清 提交于 2020-01-21 20:11:50
问题 I would like to get the count of only items inside this file with sellingstatus->sellingstate of EndedWithSales ONLY, and perhaps also get the count for EnededWithoutSales . <sellingStatus> <currentPrice currencyId="USD">25.0</currentPrice> <convertedCurrentPrice currencyId="USD">25.0</convertedCurrentPrice> <bidCount>1</bidCount> <sellingState>EndedWithSales</sellingState> </sellingStatus> How would I go about passing this argument in php? Here is a link to the sample of XML: http:/

Count items by condition with XML and PHP?

匆匆过客 提交于 2020-01-21 20:11:31
问题 I would like to get the count of only items inside this file with sellingstatus->sellingstate of EndedWithSales ONLY, and perhaps also get the count for EnededWithoutSales . <sellingStatus> <currentPrice currencyId="USD">25.0</currentPrice> <convertedCurrentPrice currencyId="USD">25.0</convertedCurrentPrice> <bidCount>1</bidCount> <sellingState>EndedWithSales</sellingState> </sellingStatus> How would I go about passing this argument in php? Here is a link to the sample of XML: http:/

Count items by condition with XML and PHP?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-21 20:11:05
问题 I would like to get the count of only items inside this file with sellingstatus->sellingstate of EndedWithSales ONLY, and perhaps also get the count for EnededWithoutSales . <sellingStatus> <currentPrice currencyId="USD">25.0</currentPrice> <convertedCurrentPrice currencyId="USD">25.0</convertedCurrentPrice> <bidCount>1</bidCount> <sellingState>EndedWithSales</sellingState> </sellingStatus> How would I go about passing this argument in php? Here is a link to the sample of XML: http:/

Count on Spark Dataframe is extremely slow

落花浮王杯 提交于 2020-01-21 03:26:32
问题 I'm creating a new DataFrame with a handful of records from a Join. val joined_df = first_df.join(second_df, first_df.col("key") === second_df.col("key") && second_df.col("key").isNull, "left_outer") joined_df.repartition(1) joined_df.cache() joined_df.count() Everything is fast (under one second) except the count operation. The RDD conversion kicks in and literally takes hours to complete. Is there any way to speed things up? INFO MemoryStore: Block rdd_63_140 stored as values in memory

Get Number of Rows from a Select statement

与世无争的帅哥 提交于 2020-01-21 02:49:26
问题 I have this: $dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$mdbFilename", $username, $password); $sql = "SELECT * FROM this_table"; $stmt = $dbh->query($sql); //num of rows? How do I get the number of rows returned from that SELECT statement? Thanks all 回答1: SELECT count(*) FROM this_table is an option... Regarding rowCount: PDOStatement::rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding