0
I have a table with the Ctrlcarganum field that has a record of the cargo number of a truck. I need to make a consultation that brings the total of this field. Until I could make the consultation see:
SELECT COUNT (*) CtrlCargaNum
FROM CTRL_CARGA
WHERE CtrlCargaData BETWEEN '2018-01-01' AND '2018-01-04' AND EmpCod = '01.01'
Only it counts only the records that are on these dates.
I would like him to take the repeating charge number and count as 1 CHARGE
Ex:
CtrlCargaNum = 1001
CtrlCargaNum = 1001
= 1 CARGA
CtrlCargaNum = 1002
CtrlCargaNum = 1002
CtrlCargaNum = 1002
= 1 CARGA
and add these charges: 1 LOAD + 1 LOAD = 2. I am using mysql server
Gives the same problem as before. It has to show 19 loads but shows a total of 26
– Felipe Michael da Fonseca
@Felipemichaeldafonseca I tested the above code in both SQL Server 2017 and Mysql 5.6 and both worked. See http://sqlfiddle.com/#! 18/42138/1 and http://sqlfiddle.com/#! 9/ea2c5f5/2
– José Diz