日期:2014-05-17  浏览次数:20855 次

有没有人啊?这个问题我都问两天了,有没有人能回答啊?
select
  (select count(F_Key)*10 as cnt from C
where F_Sa = '5'
  and F_AS in (6334904174790331938)
  and F_In between TO_DATE('2012-06-27 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND TO_DATE('2012-07-26 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
)
  (select count(F_Key)*9 as cnt from C
where F_Sa = '4'
  and F_AS in (6334904174790331938)
  and F_In between TO_DATE('2012-06-27 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND TO_DATE('2012-07-26 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
)
  (select count(F_Key)*6 as cnt from C
where F_Sa = '3'
  and F_AS in (6334904174790331938)
  and F_In between TO_DATE('2012-06-27 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND TO_DATE('2012-07-26 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
  )
  (select count(F_Key)*3 as cnt from C
  where F_Sa = '2'
  and F_AS in (6334904174790331938)
  and F_In between TO_DATE('2012-06-27 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND TO_DATE('2012-07-26 23:59:59', 'yyyy-mm-dd hh24:mi:ss')
  )
  as Molecule from dual
出 ora-00923未找到要求的FROM关键字,请问怎么解决?

------解决方案--------------------
各个SELECT 之间少了运算符。变成了SELECT A B C D FROM DUAL;
------解决方案--------------------
各个内嵌SELECT语句之间少了运算符。变成了SELECT A B C D FROM DUAL;
------解决方案--------------------
SQL code

--LZ已经帮你回答了,4个select的括号后加入","或其他运算符,如果改成其他简单的写法,这样写
select count(decode(F_Key,'5',1,null))*10
    +count(decode(F_Key,'4',1,null))*9
    +count(decode(F_Key,'3',1,null))*6
    +count(decode(F_Key,'2',1,null))*3
    as Molecule
from C
where F_AS in (6334904174790331938) and to_char(F_In,'yyyy-mm-dd')='2012-06-27';

------解决方案--------------------
+
探讨
SQL code


--LZ已经帮你回答了,4个select的括号后加入","或其他运算符,如果改成其他简单的写法,这样写
select count(decode(F_Key,'5',1,null))*10
+count(decode(F_Key,'4',1,null))*9
+count(decode(F_Key,'3',1,null))*6
+count……