I have some data that looks like this: What I want is for each group which has the same radius value to have its own unique id, for example: What I don’t want is the second group with radius 10 to have the same groupid as the first group (not 1). I’m working on SQL Server but the solution should
Tag: sql
Count if the data is not unique
I have a table of store information describing which stores are linked with one another. The data might look like this: | store_id | link_num | linked_store | | 1 | 1 | 10 | | …
How to flat a subarray in Postgres?
select array[[1,2],[2,3]] Output: -[ RECORD 1 ]——– array | {{1,2},{2,3}} How do I flat the array, so I can then unnest? Expected {1, 2, 2, 3}
How to get sum of specific status or id and joining 3 table in laravel
my table this is the result I want to display john — total paid shoes and bag dave <– total of bag,’shoes is unpaid so 1000 is not added to total’ this is my controller it gives me an error the total is same in all name Answer You could look to join sub queries, that certainly would…
Is it Possible to Merge Rows in SQL from Just One Column?
I wonder if it is possible to merge multiple rows from just one column in SQL. Here’s an example of my initial table: Here’s my expected output: I do not know if it’s possible to have a table like the later one. So, any advice would be much appreciated. Answer This type of task is usually do…
Group rows by the same value in the field, while matching on partial value only
I have a table that has many rows (between a few 1000s to a few million). I need my query to do the following: group results by the same part of the value in the field; order by the biggest group first. The table has mostly values that have only some part are similar (and i.e. suffix would be different).
Query to select records belonging only to ID and SUB-ID
I’m trying to construct a query to return only the records related to a given ID and SUB-ID. In case the condition is not met I would like to return the second possibility, i.e, the second combination ID, Sub-ID. Note: The data has thousands of IDs, but only 2 Sub-Ids per ID. This is an example of input…
SQL Combining MAX and SUM
So I have one SQL table that contains the below columns: There are ~2800 unique License numbers and will have numerous FundsIn each day. I am trying to find the last date there was activity (ActivityDate) and the sum of all of the FundsIn on that MAX ActivityDate. Below is a query I’ve been trying to mo…
Trying to make a new table by pulling data from two tables and keep getting ‘Error: Every derived table must have its own alias’ on this query
I have an ‘Orders’ table and a ‘Records’ table. Orders table has the following columns: Records table has the following columns: I’m trying to pull and compile the following list of data but I keep getting an error message: Here’s my query: What am I doing wrong? Answer The…
Count BigQuery event.params based on event.key
I am attempting to count the events filtering on their parameter. For example, suppose that I have the following. Here’s the real one for the inquisitive minds out there. https://i.imgur.com/rPwmR9i.png event_params.key and event_params.value is an array of values. I need to filter out anything in that …