views:

18

answers:

2

i have a problem during count data use this query:

   SELECT A.*, 
          COUNT( B.Serial_number ) AS Qty_insp, 
          CONCAT(ROUND(A.`Reject_qty`/ COUNT(B.Serial_number)*100, 2),'%') AS NG_Ratio
     FROM oqc_defect A
LEFT JOIN inspection_report B ON A.Model = B.Model
                             AND A.Line = B.Line
 GROUP BY A.Problem_date

i get result as encryption code for NG_Ratio like : 3532e...... why its happen, how to resolve this problem?

Edit

Reject_qty                   Qty_insp                   NG_Ratio
2                             20                           10%
A: 

Why it's happening: probably it's outputting exponential formatted numbers, like 3532e-2 being equivalent to 35.32.

It's a little hard to tell since you cut off the output at the e, just as it was getting interesting :-)

I think cast() with decimal format may be able to turn that into the desired format or, alternatively, try:

ROUND (A.`Reject_qty` * 100) / COUNT (B.Serial_number), 2)

(I haven't tested this, it may not work).

paxdiablo
how to make it can show result as real answer? not as code. is that something wrong or any query that i must change?
klox
ya..i have tried this way before. but i need to add "%" in the result, so i use CONCAT. but after use it the result show as code.any idea?
klox
I know how to do it with DB2 so you may want to try the equivalent for MySQL: cast it to decimal(?,2) then cast that to char then just add the `%`. Something like `cast(cast(val as decimal(10,2)) as char) | '%'` (may need trimming).
paxdiablo
A: 
CONCAT(CAST(ROUND(A.`Reject_qty`/ COUNT(B.Serial_number)*100, 2) AS CHAR),'%') AS NG_Ratio
klox