Questions tagged as 'distinct'

1
answer

Select the first row of each group in MySQL

Suppose I have a table like this: item | group -------+-------- item a | group x item b | group y item c | group y item d | group x item e | group z And I want to select a single item to represent each group. Now, you should be thinkin...
asked by 27.08.2018 / 04:03
1
answer

Doubt in the method of using Distinct and Count together!

I have a table requests as the example below: Id | Cliente | Status 1 | XPTO | Proposta 2 | ABCD | Proposta 3 | XPTO | Venceu 4 | XPTO | Perdeu And I want to present a result like this: Cliente | Status | Qtd XPTO...
asked by 04.08.2016 / 19:24
1
answer

Count in two tables

I'm having trouble counting neighborhood items. I need to list all of the neighborhoods in City X and show the available cars and motorcycles items. In the example I just used a city for easy illustration. I used group by and left join...
asked by 31.01.2015 / 22:38
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

MD5 is good enough?

I'm working on a legacy system, which has a database with some 5 years of cumulative records without any normalization. Among other things, its purpose is to allow users to write and post posts in the same style of Twitter, but without the limit...
asked by 25.06.2016 / 14:01
1
answer

select distinct in temp table sql server

I have the following code: (it is from a table that the representatives have the same code, which generates duplicate values, I solve this by picking the most current representative, in short the last face that synchronized) / em> select dist...
asked by 04.10.2018 / 21:41
1
answer

Select Distinct

tbl_protocolos id_protocolo | protocolo | assunto 1;ra001;vazamentos 2;ra002;incendios 3;ra003;inundacoes tbl_prot_tramitacoes id_tram | id_protocolo | pdf | id_setor_origem 1;1;001.pdf;70 2;1;001.pdf;100 - **rejeitar por causa do id_set...
asked by 31.05.2015 / 00:16
1
answer

Search last record of a different group

I'm developing a small vaccine control system and I'm having a hard time performing a select. I have a record of dogs, another of types of vaccines and a third of vaccine per dog, where I group the dog's id, type id of the vaccine (v10, antir...
asked by 10.03.2017 / 17:12
2
answers

Bring repeated records of 3 columns in the same table

I have a table with transport data from my company employees: nome ! valor1 ! valor2 ! valor3 teste1 ! 6.50 ! 0.00 ! 0.00 teste2 ! 4.30 ! 2.80 ! 1.10 teste3 ! 8.40 ! 1.10 ! 0.00 teste4 ! 2.85 ! 1.10 ! 0.00 Where it is possible for the empl...
asked by 16.01.2018 / 19:43
1
answer

Use SQL Server DISTINCT Clause

Hello, I need some help! I need to do a query and bring the NIF's, without repeating. I do it like this: SELECT DISTINCT NIF FROM CustomerRegistrations But I want to bring in more columns from this table as well. But I can not do this: SE...
asked by 14.06.2017 / 16:35