I have a sample table like this: name manager country position salary Mike Mark USA Content Writer 40000 Kate Mark France SEO Specialist 12000 John Caroline USA Outreach Expert 32000 Alice Caroline Italy SEO Specialist 50000 Philip Caroline Italy Marketing Manager 30000 Julia Caroline Italy SEO Specialist 44000 I’m writing a query to get the avg. salary from the table
Tag: grouping
How to group by the amount of values in an array in postgresql
I have a posts table with few columns including a liked_by column which’s type is an int array. As I can’t post the table here I’ll post a single post’s JSON structure which comes as below I’m trying to send posts in the order they are liked (Most Liked Posts). Which should order the posts according to the number of
Oracle – Count of number of days a value has changed
I have a requirement to write a query in Oracle as shown in the screenshots below. Any help is greatly appreciated. Thanks a lot in advance. Vadi. Table with sample data: Answer This is the solution of your problem
Take oldest record in a set of rows
So, I have this problem, I have this set of records in a table TemperatureID CastingID TemperatureDateTime TemperatureValue 1421294 1073513 2021-01-07 11:53:00.000 1648 1421295 1073513 2021-01-07 11:54:00.000 1698 1421326 1073514 2021-01-07 22:00:00.000 1594 1421327 1073514 2021-01-07 22:11:00.000 1609 and this repeated many times. My problem is that I have to take only the oldest record for each set of CastingID
Mongo Group By query
I have data stored in a Mongo collection that is structured like this: I wish to construct a query that would let me sum up each count in each entry and group by requestingSupplier. For example, I would like to answer the question, for the month of January ’22, what was the sum of each entity and get a response
If null value in a Column A, then how to return the value of column B, and if also B is null, then how to move to the value of C
Have a table in Google Big Query with date, id and store columns where the goal is to keep track how many stores a customer has visited: I wish to create a SQL query which checks for date in first column (A_date). If it has a date (is not null) then keep the date If it is null then check
Tag a row based on aggregate value condition
Here is my dataset, where order is the fix sequence of each product. What I want is another column in here, lets say TagID. TagID is an int value that will based on the aggregate Count column, group it by product if it is greater or equal to 5. So the dataset would look like this: How can I accomplish
SQL Server Grouped Number Generation
I need a way in a SQL Server query to generate grouped numbers when the data switches from one specific data value to another. Based on the first two columns below and how they are ordered, how can the query generate the numbers in the third column? When the Type column changes from Prim to anything else, all the records
How to select records in the order they were inserted, and then group them by a type
I have a query I can not seem to get to work. I have a table like this: ThingID, FK_ThingTypeID, Etc… And I want to select records in the order they were inserted, but group them by type. So if the data looks in the table is in the following order: I want to get select the records like this:
Include COUNT (including 0) of grouped records
I have a table like below answers: | room | answer | |——|——–| | 001 | 3 | | 002 | 6 | | 002 | 5 | | 002 | 6 | I want to count the answers for each room. That’s …