Questions tagged as 'group-by'

2
answers

Group [group by] SQL Firebird

I would like to know if there's any way I can do a query where I can bring fields that are not in my group by . I have the following code: select sum(TAB_FATURAMENTO.vl_item),CLIENTE.insc_cnpj from TAB_FATURAMENTO inner join (IMP_PROC...
asked by 07.08.2017 / 17:09
1
answer

Doubt group by + sum function

I have a problem putting a query into my mysql database for attendee attendance at an event. I have a participant table where I have participant information, and it has the attendance of those participants on days 1, 2 and 3 (th...
asked by 11.04.2016 / 21:45
1
answer

MySQL GROUP BY - Error in PHP

I have a query in MySQL that, in the command line and in MySQL Workbench, is bringing the correct values, but when executed in PHP, the GROUP BY function is grouping more than it should! Here is the query: SELECT DATE_FORMAT(ctg.d...
asked by 25.02.2016 / 19:17
2
answers

How do I group texts in MySQL

I tried to find a solution to this case, and I need your help. I have the following table: hora data tarefa 10:00 02/01/19 A 10:00 03/01/19 B 11:00 02/01/19 C Considering that today is 02/01/2019, when making the...
asked by 02.01.2019 / 17:04
1
answer

Consolidate all columns in only one row MYSQL

I'm trying to make a query that aggregates all the results in a single line, ie, does not bring duplicate results. I've already used distinct and group by but none of the two returned me what I need. My query is as follows:...
asked by 18.07.2018 / 01:27
2
answers

SQL - group by, count

Good afternoon, I currently have the following code and result. Instead of having this result, I would rather have only one line for each type (column 1), this line being the one whose column 4 has the highest value. If anyone can help (I'm a be...
asked by 20.05.2018 / 14:56
1
answer

Join two SQL queries MariaDB

Two tables tab_Ord_Ser and tab_Pos_Alb . In two different queries I can know the values but I can not unite them in just one. These are: SELECT Prazo_Producao as Data, COUNT( 'Numero OS' ) AS Produzir, Tipo_Album FRO...
asked by 24.04.2018 / 21:18
1
answer

Mysql - Order before grouping

I need to make a selection that will bring the last users who logged in without repeating the names. The problem is that the command below first groups and then sorts: SELECT usuario FROM tab_logins GROUP BY usuario ORDER BY data_login desc...
asked by 11.03.2018 / 17:47
1
answer

How to Join with Sum and Group By

I'm trying to do a SQL query using Join between two tables. The first table is a table that contains monthly savings values for a given project. Each time someone registers a project on the site, a PHP routine generates 12 values, one in the cur...
asked by 24.01.2018 / 22:27
0
answers

Group by only 1 result

I have a problem with my query in MySQL: SELECT * FROM 'campeonatos' INNER JOIN 'jogos' ON 'campeonatos'.'camp_id'='jogos'.'campeonato_id' WHERE 'jogos'.'inicio' > "2017-10-30 00:00:00" ORDER BY 'campeonat...
asked by 30.10.2017 / 15:35