Questions tagged as 'group-by'

4
answers

Return all equal items from different groups

------------------- - TABLE - ------------------- ID | GRUPO | OBJETO ---|-------|------- 1 | 1 | 1 2 | 1 | 2 | | 3 | 2 | 1 4 | 2 | 2 | | 5 | 3 | 1 6 | 3 | 2 7 | 3 | 3 | | 5...
asked by 03.09.2015 / 09:53
2
answers

How does GroupBy work in LINQ?

I'm having trouble understanding the GroupBy operator in LINQ.     
asked by 26.08.2015 / 21:23
3
answers

How to get the value of a column corresponding to the maximum of another column?

I have a table with columns codigo , data and valor . I would like to get, for each code, the value corresponding to the most recent date. In what ways can this be done? And if there is more than one, which is the most efficie...
asked by 03.08.2014 / 19:57
2
answers

What is the most efficient way to implement GroupBy in Javascript?

I'm trying to implement a GroupBy with these parameters function GroupBy(keySelector, elementSelector, comparer) { // keySelector = function(e) { return e.ID } // elementSelector = function(e) { return e.Name } // comparer =...
asked by 17.12.2013 / 13:56
1
answer

Error when using Group by in a VIEW in Mysql

I created a VIEW to return the main data I need in a single query. CREATE ALGORITHM = UNDEFINED DEFINER = 'root'@'localhost' SQL SECURITY DEFINER VIEW v_historicoProcesso AS SELECT p.protocolo AS protocolo ,p.der AS der ,p.dat...
asked by 05.12.2015 / 23:18
1
answer

Problem with group by

I have the following query: SELECT funcionario.*, emprego.data_admissao, emprego.data_saida, emprego.data_dispensa FROM funcionario,emprego,empresa WHERE empresa.id = emprego.id_empresa AND funcionario.id = emprego.id_funcionario AND em...
asked by 20.11.2017 / 17:04
3
answers

Over with Group by

I have a query that I use to return as an extract, accumulating the registry values to registry: SELECT TOP (100) PERCENT Mes, Credito, Debito, Sum(Credito - Debito) over (ORDER BY Emp_id, Mes) AS Saldo , Emp_id FROM viewFluxo ORDER BY...
asked by 06.09.2017 / 19:29
4
answers

Get the highest value by category by also loading the ID

The table is in the format below ID | CATEGORIA | QUANTIDADE 1 | A | 23 2 | A | 12 3 | A | 11 1 | B | 15 2 | B | 10 I want a query to return the following table ID | CATEGORIA | QUANTIDAD...
asked by 21.10.2015 / 23:10
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
3
answers

Group by interval of days using Linq

How can I use interval grouping with Linq? var dados = new[] { new { Id = 0, dias=100, preco= 25, Nome="etc"}, new { Id = 1, dias=40, preco= 50, Nome="etc1"}, new { Id = 2, dias=50, preco= 55, Nome="etc2"}, new { Id = 3, d...
asked by 08.06.2017 / 21:57