How can I improve this query for speed? at the moment it’s taking a couple of seconds only to load the php file where the query is without even querying anything. I’ve an index on skillsTrends, jobtitle and industry. Collation: utf8mb4_unicode_ci Number of records < 1,000,000. Answer Try this c…
Tag: count
How to create new count column based on adjacent combinations in existing table
I have a simple table I’ve already built in BigQuery and all I want to do is what feels like a simple count of the number of times the combination of the person_id and the specific activity in the activity column has appeared in that table and create as a new column with a value/count of the adjacent co…
SQL: How to divide column by counts?
So I have this query This will print something like device_id paper_count 1 5000 2 10000 And I have this other other query that will return the number of times the toner has been changed according to some date. I used count to count the number of times it’s been changed. This will print something like d…
How to use multiple count distinct in the same query with other columns in Druid SQL?
I’m trying to use three projections in same query like below in a Druid environment: But instead I get an error saying – Unknown exception / Cannot build plan for query It seems to work perfectly fine when I put just one count(distinct) in the query. How can this be resolved? Answer As the Druid d…
COUNT to return NULL as 0 in same table in SAS PROC SQL with GROUP BY
I am having a task where I have 1 table. There is a unique ID for transactions, transaction dates, and store names. My task would be to count the number of transactions every store made during March. This, in itself, is simple: This would lead to a table where a store is present only if it had a transaction i…
How to count a foreign key and use it to sort the primary table?
I have 2 tables: Product (prod_id, prod_name, vend_id) Vendor (vend_id, vend_name, vend_state) I am trying to make a query that will give me a list of the vend_name for every vendor that supplied only one product. vend_id is a foreign key in Product, and I would like to count how many instances of each vend_i…
How to add data to a field based on other fields in a SQL database
I have an SQLite table called wcvp constructed from a csv file downloaded from the World Check List of Vascular Plants (see https://wcvp.science.kew.org/ and http://sftp.kew.org/pub/data-repositories/WCVP/). When I run this query: I get this result: kew_id genus species infraspecies 304293-2 Quercus robur 771…
Subquery to get derived value
I have the below table T in MySQL, with columns A and B. I want to query this table to get a value ‘C’, that has the count of the number of times the value in Column ‘A’ appears in Column ‘B’. For example, 1 appears 2 times in Column B, so the first row of column C should b…
How to count the number of entries in the list when requesting Select?
I apologize for the possible incorrectness in the presentation, I use a translator. Let’s say there is a users table in which there is an id field. And there is a list that lists the id numbers and some of them are repeated. My query returns the following 3 – 1, 10 – 1. And I would like to g…
SUM aggregation do not work on empty subqueries with DRUID
Assuming I am executing the following two queries on Druid: I tried to combine both counts in one single query with a sum aggregation like the following: And it works well UNLESS one of the two counts returns 0 rows. In that case I receive a Query returned no data message and I don’t have any final resu…