Questions tagged as 'group-by'

1
answer

Group by equality

I need to group the result when there are equal records, regardless of order, whenever the same colors are chosen - group colors and users together. I need to produce an output like the one below: 0 => array( 'cores' => 'azul, verde' , '...
asked by 13.02.2015 / 00:38
1
answer

Difficulty in grouping and where clause in MySql

I need to search the database for the last 4 most recent records, with the exr_exa_id column matching the reported id's, and exr_exa_id can not be duplicated. I tried to group in a few ways, but I was not successful, because it...
asked by 13.08.2015 / 20:30
1
answer

SQL distinct with sum

Hello, I have a problem making a sum in a query. Query example and results: select DISTINCT t.ID, t.nomeuc as "Nome UC", t.tipoturno as "Tipo Turno", a.num_presencas as "Número de Presenças" from ei_sad_proj_gisem.v_aulas_semana a jo...
asked by 03.11.2017 / 22:06
2
answers

doubts with query in sql

I have a table with 5 fields: id name charge salary data ... and I wanted to make a query that would return the names of the people with the highest salary, of each position, for example I have 3 positions: analyst, dev and engine...
asked by 21.07.2017 / 13:19
2
answers

LEFT JOIN with GROUP BY

I'm using PHP and MySQL, I have two tables in the database: POSTAGEM id ---- 1 3 13 CURTIDA id | id_usuario | id_postagem ----------------------------- 1 | 1 | 1 7 | 12 | 1 What I can not do is the following:...
asked by 27.09.2017 / 19:16
2
answers

How do I list all the fields in a table plus a random value from another table?

I'm having a problem when dealing with two tables, tb_adm_anuncios and tb_adm_anuncio_banner . For each ad I have 4 banners, and to list those ads I need: **Anúncio:** -Nome do Anúncio -Link **Banner:** -Imagem The command...
asked by 27.07.2017 / 16:33
1
answer

Error when grouping table field

I need to group the data of a SELECT by the a.afo_vch_NmrCtf field, because the data is being returned as follows: When I use GROUP BY the following error is returned: Msg 8120, Level 16, State 1, Line 2 Column 't...
asked by 22.09.2016 / 15:30
2
answers

Difficulty in returning the result in a query without duplicating

I am trying to set up a query (MYSQL) to return all the clients that a particular vendor can view. The rules for showing the list of customers for this seller are: - Clients with overdue contracts or without contracts. - Customers with bids or n...
asked by 24.10.2017 / 15:17
1
answer

Group items in table application asp.net web MVC

How can I group items in a table? I am bringing these items from the database, I would like to group by the code of the same, for example, if there is repeated code 1 would like to group it into a single item. This is the controller class. This...
asked by 03.12.2017 / 15:27
1
answer

MySQL query problems

I am having difficulty querying between 4 tables, being them. States > Municipalities > Deaths > Population The query is returning the value of the population with a higher than true number ... Can anyone help me with this query? se...
asked by 05.10.2016 / 21:43