开发者

mysql: result counting data as encryption

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.Prob开发者_高级运维lem_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%


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).


CONCAT(CAST(ROUND(A.`Reject_qty`/ COUNT(B.Serial_number)*100, 2) AS CHAR),'%') AS NG_Ratio
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜