Equatorial Guinea and Dominican Republic have all of the vowels (a, e, i, o, u) in the name. They don’t count because they have more than one word in the name. You can use the phrase name NOT LIKE ‘%a%’ to exclude characters from your results. The query shown misses countries like Bahamas and Belarus because they contain at least
SQL – Distribution Count
Hi I have the following table: I would like to show the following: Basically I want to count the number crm_ids that have 1,2,3,4,5+ customer_ids. Thanks Answer One approach is to aggregate twice. First, aggregate over crm_id and generate counts. Then, aggregate over those counts themselves and generate a count of counts. Have a look at a demo below, given
Percentage from Total SUM after GROUP BY SQL Server
I have these results: With the table like: These are grouped by the person. Now I’m looking to add a column with the percentages for each person calculated from the total of all of their sums. For example: the total sum is 300, and hence I need a result like this: I have looked at code online and I have
How to get maximum number of concurrent events in postgresql?
I have a table named events like this: These events could have overlaps, and I want to know maximum number of overlapping events that have occurred over a time span. For example, in a situation like this: The answer is 2, because at most 2 events overlap at 10:30 until 10:35. I’m using Postgres 9.6 Answer Here is the idea:
Case When syntax expression in jooq
I am trying to reproduce this MySQL query in jooq to Answer What you seem to be looking for is the SQL:2003 simple CASE expression, which allows to form something like “partial predicates” based on the case value, akin to pattern matching in other languages. This is not yet supported in jOOQ, see Issue #3223. Interestingly, though, your SQL example
How can I have IS NULL condition in TypeORM find options?
In my queries I’m using TypeORM find option. How can I have IS NULL condition in the where clause? Answer Another way is you can use IsNull() function, for example:
Making dynamic SQL queries to a MySQL DB
I’ve never used golang with mysql before, so I’m reading about these for the first time. I’d like to do something like this: This is far too much typing, especially if I have a dozen more variables I’d like to add to the WHERE condition. If this were PHP, I’d do something like this: By using a foreach loop, I
SQL Insert Into New Table from Old Table
I’ve got two table which are near identical, the only difference is the newer one has different field names. Basically the old table was outdated and needed to be re-worked; I’m trying to extract all the field where the VendorNumber = Vendor_ID all the field that are being copied to are guaranteed empty. The below SQL code if very large,
Concatenate with string but exclude when null
Oracle v11 Exclude a string in a Concat when the value is NULL? Work Query: TableA Output I’m getting Expected Output: Answer Something like this… I added simulated inputs to test all four possibilities. However, note that if you may have last name but no first name, and also first name but no last name, the combined column will show
Finding the maximum distance between events in a group in gdelt-bq.full dataset, BigQuery
I need to find the longest distance across all the event points for each country in gdelt-bq.full:events dataset. For having information about countries make groups there is a join with gdelt-bq:extra.countryinfo. So now I have this table: The difficulty is that there are around 50k events in total, and maximum within a group is 15K (for US) and I need