select 的过程中中文乱码问题求教
select dates,concat(concat(replace(replace(TRUNCATE(part * 0.5 – 0.5 * 1.0,1),’.5′,’点30分’),’.0′,’点’),’ 至 ‘),
replace(replace(TRUNCATE(part * 0.5 * 1.0,1),’.5′,’点30分’),’.0′,’点’)) as part_name,
sum(case role when 0 then 1 else 0 end) as call_in,
sum(case role when 0 then billsec else 0 end) as call_in_billsec,
sum(case role when 1 then 1 else 0 end) as call_out,
sum(case role when 1 then billsec else 0 end) as call_out_billsec
from(
SELECT substring(c.calldate,1,10) as dates,s.role,c.billsec,
ceil((HOUR(c.calldate) + MINUTE(c.calldate)/60 + SECOND(c.calldate)/3600 + 1/3600)/0.5) as part
from cdr as c,callsession as s
where c.userfield = s.callsessionid
) as a
group by dates,part
查询结果如下
-03-05 14点 至 14点30分 2 10 2 13
-03-06 10点 至 10点30分 0 0 2 12
-03-06 12点30分 至 13点 1 6 2 10
-03-06 14点 至 14点30分 0 0 6 65
-03-06 15点 至 15点30分 1 6 20 43
-03-06 15点30分 至 16点 1 26 22 171
-03-06 16点 至 16点30分 6 158 9 190
-03-06 16点30分 至 17点 4 28 5 60
-03-06 17点 至 17点30分 1 4 11 59
-03-06 17点30分 至 18点 0 0 3 4
-03-14 11点 至 11点30分 0 0 13 0
但是当我在以上sql又套了一层select时
select dates,part_name from(
select dates,concat(concat(replace(replace(TRUNCATE(part * 0.5 – 0.5 * 1.0,1),’.5′,’点30分’),’.0′,’点’),’ 至 ‘),
replace(replace(TRUNCATE(part * 0.5 * 1.0,1),’.5′,’点30分’),’.0′,’点’)) as part_name,
sum(case role when 0 then 1 else 0 end) as call_in,
sum(case role when 0 then billsec else 0 end) as call_in_billsec,
sum(case role when 1 then 1 else 0 end) as call_out,
sum(case role when 1 then billsec else 0 end) as call_out_billsec
from(
SELECT substring(c.calldate,1,10) as dates,s.role,c.billsec,
ceil((HOUR(c.calldate) + MINUTE(c.calldate)/60 + SECOND(c.calldate)/3600 + 1/3600)/0.5) as part
from cdr as c,callsession as s
where c.userfield = s.callsessionid
) as a
group by dates,part
) as b
order by dates desc
查询结果就成
-04-23 14鐐?鑷?14鐐?0鍒
-04-23 16鐐?鑷?16鐐?0鍒
-04-23 13鐐?0鍒?鑷?14鐐
-03-31 10鐐?鑷?10鐐?0鍒
-03-31 9鐐?0鍒?鑷?10鐐
-03-23 15鐐?鑷?15鐐?0鍒
-03-23 14鐐?0鍒?鑷?15鐐
…….
如何解决呢?
ps: sqlserver的强制转换类型我会,但是mysql的我实现不了,也求教
——解决方案——————–
set names ‘gbk’; 先试一下。
搞代码网()提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[emailprotected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:select 的过程中中文乱码有关问题求教