Questions tagged as 'group-by'

2
answers

How can I implement the GroupBy method in TypeScript?

I have an array: interface IFoo { IDCidade: number; Nome: string } var arr = [ { IDCidade: 10, Nome: "Foo" }, { IDCidade: 10, Nome: "Bar" }, { IDCidade: 20, Nome: "Foo" }, { IDCidade: 20, Nome: "Bar" } ]; I want to group t...
asked by 14.12.2013 / 22:58
1
answer

Field SUM of two Subqueries in MSSQL

I'm needing a field derived from two subqueries that gives the sum of values based on a field. Here's an example: SQL: SELECT CodCliente ,DataVenda ,Vendedor ,Valor ,DataPagamento ,TotalCliente --> SOMA DE [Valor]...
asked by 09.02.2015 / 12:54
1
answer

Get the last message of a conversation (GROUP BY)

I have the following query: SELECT cp_mensagem.mensagem, cp_mensagem.dh_envio, cp_projeto.id as id_projeto, cp_projeto.nome as nome_projeto, cp_pessoa.id as id_freelancer, cp_pessoa.nome as nome_freelancer FROM c...
asked by 25.04.2014 / 17:58
2
answers

Group By different results

Hello, I have a question if anyone can help me about SQL. I know the Group By clause, as far as I know how to group similar data. But I understand that it should group but in the script below it has the group by show lines and without the group...
asked by 24.08.2017 / 22:16
2
answers

How to list the data of a SQL query grouped by order of data presentation

I wonder if there is a way to group records in the search order. Let's say I have a table of two Local (mapped place), Time (Date and Time) fields. Place was filled in the same place then in three different times, then I have new places and back...
asked by 15.08.2016 / 21:31
2
answers

Select too slow, how to improve?

I have a cadre of craftsmen with about 90 thousand records. I created the SQL below to return me the total of artisans in each of the regions that they are registered. Although it works, it is slow, taking more than 30 seconds to return the reco...
asked by 22.09.2016 / 19:52
1
answer

SQL Group query with more than one distinguished attribute

I have an application that generates approximately 25000 records per day in DB. This will generate a large amount of id's per day in the user's DB. According to the user's business rule, only failed inspections ( is_ok = 0 ) must be log...
asked by 30.08.2014 / 22:47
2
answers

Group Query Results Postgresql

I have the normal table with the query . status |curso |matricula| --------- |------|---------| Completo |Inglês|001 | Cursando |Mat |002 | Reprovado |Esp |003 | Completo |Inglês|004...
asked by 25.11.2014 / 00:04
1
answer

List the last users logged in (GROUP BY AND ORDER BY)

I have two tables ( user and log ), and would like to list the users by sorting by the last logged in. I'm using GROUP BY to join the logs (since a user can have more than one). The problem occurs when I add the ORDER BY , return...
asked by 23.04.2017 / 15:52
1
answer

Javascript - Sum and Group By in Array

I would like a tip / help. I'm working with a series of JSON files, and applying filters to them as the user progresses through the system. So far so good, I managed to do it quietly using .filter() . My problem is in the n...
asked by 11.02.2016 / 17:11