Questions tagged as 'sum'

3
answers

RETURN THE SUM OF MAXIMUM 3 VALUES IN SQL

I have a table and need to return the following: check based on the recipient column, add up the 3 largest amounts of that recipient, bring in the query only if the sum of the 3 largest are > = 1024: CREATE TABLE TRANSFERS( SENDER VARCHAR2(...
asked by 12.06.2018 / 19:56
1
answer

Multiplication and sum of dynamic inputs

Note: Developed with Laravel 5.7. Note 2: This is the "New Order" view. The form will dynamically receive the products according to their previously registered items. Until then, okay! The user will bookmark the product and enter the desi...
asked by 13.12.2018 / 15:25
1
answer

Divide sum and count result into the same Query?

The code below works, but I wanted to know how to do it all right in query , and if the way I'm setting it up is really the best way. $query = Avaliar::select(DB::raw('COUNT(id) as contar'), DB::raw('SUM(nota) as total')) ->where('...
asked by 19.12.2017 / 05:14
1
answer

Count and group by day

SELECT loc.loc_pac as registro, datediff(dd, pac.pac_nasc, getdate()) as 'dias' from loc with (nolock), pac with (nolock), str with (nolock) where loc.loc_pac <> '' and (loc.loc_pac = pac.pac_reg) and (loc.loc_str = str.str_cod) order...
asked by 29.06.2018 / 02:27
2
answers

How to get the sum of an entire column in SQLSERVER

I need to get the total value of the VOL field (image below), it is already generated by the SUM function. It can be in another query. All periodic tithe is required. ex: total = VOL (7.6890028) - > sum of the 4 lines of column VOL...
asked by 03.05.2018 / 21:56
1
answer

Sum (SUM) of a column with irregular formatting

In my MySQL table I have a column called "weight". This column has the following values: 19.325 14.369 15.325 15.369 17.698 19.258 18.098 I simply need to do the sum, but when I run select sum(peso) from tabela it returns me the valu...
asked by 18.06.2018 / 15:58
2
answers
1
answer

When Calculating quantity greater and less than Average returns error in SQL SERVER

In Columns: SUM(CASE WHEN cqd.queuetime < AVG(cqd.queuetime) THEN 1 ELSE 0 END) as 'Qtde < Média' e SUM(CASE WHEN cqd.queuetime > AVG(cqd.queuetime) THEN 1 ELSE 0 END) as 'Qtde > Média', returns the following error in SQL SERVER...
asked by 30.11.2018 / 14:05
1
answer

Adding grouped total sum to a new DataFrame pyspark column

I have a dataframe with the following columns: COL1 COL2 COL3 NEW_COL* A asd 1 8 B adf 2 9 A adg 8 1 B adh 9 2 C adj 7 7 D adk 1...
asked by 30.05.2018 / 23:32
1
answer

Postgresql Database

How do I make a select with sum and inner join to add a value x between 3 tables. A query return to the lowest possible number of results. create table credit_card ( credit_card_id int primary key, nome varchar...
asked by 28.01.2018 / 10:34