I have following data in my PostgreSQL 11 database count_tbl (Windows 10 x64 machine). The following query, for each group (grp), finds the most frequent value: The output of above query is: Now, I would like to associate the most frequent value to the corresponding IDs (for example, for grp = 1, most frequent value 19.7 have ids 1, 2,
Tag: count
How do i use COUNT with JOIN SQL 3 tables
I have 3 tables. First table is Battles with columns: –battleId(primary)–gameId(foreign)–prize– Second table is Games with columns: –gameId(primary)–gameName– Thrid table is …
Group by not getting the expected results in mysql
I have the next query: That is working perfectly and returning 9 rows: I want to group the results by boat type and get the number of boats per type. However, when I do: I´m getting: but according to the first query, I´m expecting What am I missing? Answer I suspect that you want: That is: move the DISTINCT within
Find total count and average based of values from another table
In Mysql: I have customer name (primary key), cities and an amount in table: Table Cities: customer location amount Cust1 New York, USA 200 Cust2 New York, USA 300 …
Combining query results for number of records in a single row
I am new to SQL. I have a table that has billion of records with multiple columns, let’s say a,b,c,d,e,f. I would like to create a query for number of records for each column with certain condition …
MYSQL SUM(IF) with group by NAME but some NAME wanna makes sum
I have one question in SQL. This is the query. it makes a result below: but I wanna make Customer A and B sum together as A(not B) or new name(e.g. Z) like this: I want to modify the query and output it. Answer I understand that you want to group together customers A and B. You can do this
Inner join with Count, multiple tables
I’m having an issue with MS Access to get correct counts on multiple tables. I’m not at all an expert in SQL requests. I have a set of tables which is structured as follow : Table1 : UID, Name, other informations Table2 : UID, FK_UID_Table1, Name, other informations Table3 : UID, FK_UID_Table2, Name, other informations Table4 : UID, FK_UID_Table3, Name,
Mysql Group By age by range [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question i need help, i need to create report like this the report is group by the age, but i can’t get when age under <=
SQL statement HOW to count all relevant rows (A,B) and (B,A) together
I am trying to count all rows where seller and buyer has also an inverted relationship. So the buyer sells to seller. I do not have any clue to group them together. Table T1| ———————- …
Selecting new distinct values over time (ORACLE SQL)
I want to select new distinct values and track them over time. I have a table where each row represents a score awarded to a particular person. – timestamp (when the score was awarded) – name (which person received the score) – score (what score the person received) I want the result to look like: The above table should be