on ‎2023 May 04 1:00 PM
SELECT distinct T2.[SlpName], count(distinct(CONCAT(T0.[U_numConteneurLiv],T0.[TaxDate]))) AS "NB TCs",
( select count(distinct(CONCAT(A.[U_numConteneurLiv],A.[TaxDate]))) as 'TTL CT'
from ODLN A
where A.DOCDATE LIKE '%%2023%' and A.canceled='N' ) as 'TTL CT' , 17/157 'Test',
(isnull(count(distinct(CONCAT(T0.[U_numConteneurLiv],T0.[TaxDate]))),0) / 157 ) *100 as '%'
FROM ODLN T0
INNER JOIN DLN1 T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN OSLP T2 ON T0.[SlpCode] = T2.[SlpCode]
where t0.DOCDATE LIKE '%%2023%' and t0.canceled='N'
group by T2.[SlpName]
I want to calculate the following percentage but it returns 0 in the result (using division )
any body have idea about my problem?
Regards .
This is what result SQL

Request clarification before answering.
Hi,
Please change this:
17/157 'Test',
(isnull(count(distinct(CONCAT(T0.[U_numConteneurLiv],T0.[TaxDate]))),0) / 157 ) *100 as '%'to this:
17.0/157.0 'Test',
(CAST(isnull(count(distinct(CONCAT(T0.[U_numConteneurLiv],T0.[TaxDate]))),0) AS NUMERIC(19,6)) / 157.0 ) *100 as '%'Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 30 | |
| 14 | |
| 9 | |
| 4 | |
| 4 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.