首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

请问Oracle中的这个SQL语句如何写

2012-03-31 
请教Oracle中的这个SQL语句怎么写在ACCESS中SELECTT.sTrainNo,T.sTrainName,C.cCount,C.iSum,U.iCount,L.s

请教Oracle中的这个SQL语句怎么写
在ACCESS中

SELECT   T.sTrainNo,   T.sTrainName,   C.cCount,   C.iSum,   U.iCount,   L.sName   AS   LName,   N.sContentName,   S.sSchoolName,   S.sAddress,   T.dTrainDate   FROM   ((((BaseTerm   AS   T   INNER   JOIN   BaseSchool   AS   S   ON   T.iSchoolID   =   S.iID)   INNER   JOIN   BaseLevel   AS   L   ON   T.iTrainLevelID   =   L.iID)   INNER   JOIN   BaseContent   AS   N   ON   T.iTrainContentID   =   N.iID)   LEFT   JOIN   (SELECT   sTrainNo,   COUNT(*)   AS   cCount,   SUM(iNum)   AS   iSum   FROM   BaseClass   GROUP   BY   sTrainNo)   AS   C   ON   C.sTrainNo   =   T.sTrainNo)   LEFT   JOIN   (SELECT   sTermID,   COUNT(*)   AS   iCount   FROM   SignUp   GROUP   BY   sTermID)   AS   U   ON   T.sTrainNo   =   U.sTermID   Where   T.dTrainDate   > =   '2005-07-30 '   AND   T.dTrainDate   <=   '2007-07-30 '
说明:
BaseTerm   与   BaseSchool,   BaseLevel,   BaseContent   进行内连接后会生成一个视图
这个试图在外连接   C视图和D视图
这个语句在ACCESS中执行是没有问题的。
因为Oracle版本9.2中没有Inner,请问如果解决



[解决办法]
SELECT T.sTrainNo, T.sTrainName, C.cCount, C.iSum, U.iCount, L.sName LName,
N.sContentName, S.sSchoolName, S.sAddress, T.dTrainDate
FROM ((((BaseTerm T INNER JOIN BaseSchool S ON T.iSchoolID = S.iID)
INNER JOIN BaseLevel L ON T.iTrainLevelID = L.iID)
INNER JOIN BaseContent N ON T.iTrainContentID = N.iID)
LEFT JOIN (SELECT sTrainNo, COUNT(*) cCount, SUM(iNum) iSum
FROM BaseClass GROUP BY sTrainNo) C ON C.sTrainNo = T.sTrainNo)
LEFT JOIN (SELECT sTermID, COUNT(*) iCount FROM SignUp GROUP BY sTermID)
U ON T.sTrainNo = U.sTermID
Where T.dTrainDate > = '2005-07-30 ' AND T.dTrainDate <= '2007-07-30 '
[解决办法]
改一下吧

Where T.dTrainDate > = to_date( '2005-07-30 ', 'yyyy-mm-dd ') AND T.dTrainDate <= to_date( '2007-07-30 ', 'yyyy-mm-dd ')

热点排行