cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Division sql return 0

mari_outtaleb96
Participant
0 Likes
377


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

Accepted Solutions (1)

Accepted Solutions (1)

Johan_Hakkesteegt
Active Contributor
0 Likes

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

Answers (0)