SQL语句一直报无效数字的错,为什么?
selectcount(in_date)fromcar_goods_infowhereto_date(in_date,'yyyy-MM-ddHH24:mi:ss')bet...
select count(in_date) from car_goods_info where to_date(in_date,'yyyy-MM-dd HH24:mi:ss') between to_date('2014-04-25 00:00:00','yyyy-MM-dd HH24:mi:ss') and to_date('2014-04-25 23:59:59','yyyy-MM-dd HH24:mi:ss') group by to_char(in_date,'hh24');
in_date是varchar2类型的 展开
in_date是varchar2类型的 展开
展开全部
SELECT COUNT(IN_DATE)
FROM CAR_GOODS_INFO
WHERE TO_DATE(IN_DATE, 'yyyy-MM-dd HH24:mi:ss') BETWEEN
TO_DATE('2014-04-25 00:00:00', 'yyyy-MM-dd HH24:mi:ss') AND
TO_DATE('2014-04-25 23:59:59', 'yyyy-MM-dd HH24:mi:ss')
GROUP BY SUBSTR(IN_DATE, 12, 2);
改成这样子,你最后又把IN_DATE当做date用了
FROM CAR_GOODS_INFO
WHERE TO_DATE(IN_DATE, 'yyyy-MM-dd HH24:mi:ss') BETWEEN
TO_DATE('2014-04-25 00:00:00', 'yyyy-MM-dd HH24:mi:ss') AND
TO_DATE('2014-04-25 23:59:59', 'yyyy-MM-dd HH24:mi:ss')
GROUP BY SUBSTR(IN_DATE, 12, 2);
改成这样子,你最后又把IN_DATE当做date用了
追问
好吧截取字符串就截取字符串吧- - 为什么会是乱序的?
追答
额 排序一下就行了晒
SELECT SUBSTR(IN_DATE, 12, 2),COUNT(IN_DATE)
FROM CAR_GOODS_INFO
WHERE TO_DATE(IN_DATE, 'yyyy-MM-dd HH24:mi:ss') BETWEEN
TO_DATE('2014-04-25 00:00:00', 'yyyy-MM-dd HH24:mi:ss') AND
TO_DATE('2014-04-25 23:59:59', 'yyyy-MM-dd HH24:mi:ss')
GROUP BY SUBSTR(IN_DATE, 12, 2)
ORDER BY SUBSTR(IN_DATE, 12, 2);
是字符串你还当做时间用,服你,实在要用,
TO_DATE(TO_DATE('2014-04-25 23:59:59', 'yyyy-MM-dd HH24:mi:ss'),'hh24')
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |