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

这个语句怎么写??????????急求!!!!!!!!!!!
SELECT OFU.A,OFU.NUM1,OS.NUM2, CONVERT((DECIMAL(10,2), CONVERT((DECIMAL(10,2),OS.NUM2)/OFU.NUM1)
  FROM (SELECT F_A,COUNT(*) NUM1
  FROM CR
  WHERE F_ITime>= to_date('2008-12-27','yyyy-mm-dd')
  AND ITime < to_date('2008-12-27','yyyy-mm-dd')
  AND S IN (0,1,2)
  AND SType IN (10,17)
  HAVING COUNT(*)>0)OFU 
  INNER JOIN (SELECT A,COUNT(*) NUM2
  FROM CR
  WHERE ITime>= to_date('2008-12-27','yyyy-mm-dd')
  AND ITime < to_date('2008-12-27','yyyy-mm-dd')
  AND F_SResult = '110' AND F_ServiceMode IN (0,1,2)
  AND F_SType IN (10,17)
  GROUP BY A
  HAVING COUNT(*)>0)OS ON OS.A = OFU.A

ORACLE怎么写啊????????????

------解决方案--------------------
SQL code
SELECT OFU.A,OFU.NUM1,OS.NUM2, to_char(to_number(OS.NUM2)/OFU.NUM1, '99999999.99'),
  FROM (SELECT F_A,COUNT(*) NUM1
  FROM CR
  WHERE F_ITime>= to_date('2008-12-27','yyyy-mm-dd')
  AND ITime < to_date('2008-12-27','yyyy-mm-dd')
  AND S IN (0,1,2)
  AND SType IN (10,17)
  HAVING COUNT(*)>0)OFU  
  INNER JOIN (SELECT A,COUNT(*) NUM2
  FROM CR
  WHERE ITime>= to_date('2008-12-27','yyyy-mm-dd')
  AND ITime < to_date('2008-12-27','yyyy-mm-dd')
  AND F_SResult = '110' AND F_ServiceMode IN (0,1,2)
  AND F_SType IN (10,17)
  GROUP BY A
  HAVING COUNT(*)>0)OS ON OS.A = OFU.A