Questions tagged as 'group-by'

3
answers

Top 1 for each group in a Group by SQL Server

I have a table similar to this one CancelLog |ID| membrecia| User | DateCancel | Motivo | | 2| 1 | uS1 | 7/29/2011 | ... | | 3| 1 | uS2 | 7/30/2011 | ... | | 6| 1 | uS1 | 8/02/2011 | ... | |...
asked by 17.03.2017 / 22:16
1
answer

Group By, and create new columns for the PostgreSQL result

I have the following problem: I have my table access In this table I relate the Role with a Module and the Permission it has. What I want is to create a view that returns the data to me in the following way: View returning th...
asked by 23.05.2018 / 23:28
1
answer

Doubt in query SQL group by and nulls

Fiddle to test queries: link    Let's say I have a table like that. +-------------+-------------+------------------+-------------+ | Cod | Provincia | Cliente | tlfn | +-------------+-------------+--------------...
asked by 09.03.2018 / 08:29
2
answers

Group consecutive duplicates in python

I am wanting to do a grouping of rows in a dataframe, but only of the consecutive ones. To put it more clearly, I give an example: ip_src ip_dst packet_length src_port dst_port comm_type 0 192.168.0.7 52.31.84.22 28...
asked by 15.05.2018 / 05:13
1
answer

help with group by in mysql

I have to take out the total amount for each unit that I have in my table, the problem is that a record that supposedly belongs to unit 3 belongs to unit 1, I do not know how to group it so that it is correct, this is my query. select SUM(TOTA...
asked by 21.06.2018 / 19:38
1
answer

Problem with SQL statement when wanting to group (Group By)

The problem lies in the moment in which I want to execute the following sentence: SELECT Id_Temporada, IdSerie, NombreTemporada, NumeroTemporada, Id_TemporadaC, Id_CapituloT, NombreCapitulo, NumeroCapitulo, DescripcionCapitulo...
asked by 21.06.2018 / 20:49
1
answer

SQL Group SUM by idemployed

good and tried in different ways to try to group a sum of 3 tables I will write the example to be clearer SELECT v.fecha_ven, e.apellidopaterno_emp, e.nombre_emp, SUM(d.precio_dv * d.cantidad_dv) AS Total FROM detalle...
asked by 20.12.2018 / 22:34
1
answer

Add the value of each period and put 0 in the periods that do not exist in SQL Query table

I have two Income and Periods tables, within the Periods table are the months from January to February and in Income I have a value_port column in which there are records for what has been contributed in each month. ex. Ingresos Periodo Valor_...
asked by 06.04.2018 / 23:02
0
answers

LINQ: Query GROUP BY conditional COUNT

How is it possible to move this type of operation to Linq ... in SQL:    COUNT (CASE WHEN VALUE="EXAMPLE" then 1 else = 0 END) Within a GROUP BY statement In linq? from join... from... group new { contador = tabla.Count(x=...
asked by 22.06.2017 / 14:19
2
answers

Function group by on column type varchar does not work

I have a query in which I count the rows grouped by a type code varchar should count 1 but count the 3, you could see that it is wrong the grouped column is ID_CURSO_UNICO SELECT count(ID_CURSO_UNICO) as cantidad from encuesta_ap...
asked by 13.08.2017 / 20:01