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

比较两个SQL语句

SELECT  styleid
FROM    d_sked i
        INNER JOIN d_skedsub ON i.skedid = dbo.d_skedsub.skedid
WHERE   styleid IN ( SELECT styleid
                     FROM   dbo.J_style
                     WHERE  styleid IN ( SELECT styleid
                                         FROM   dbo.sys_stylepower18ql s
                                         WHERE  s.userid = 'Z655'
                                                AND s.access = 1 ) )
        AND i.sure > 0
        AND ( CONVERT(VARCHAR(10), i.sure_date, 120) BETWEEN DATEADD(year, -1,
                                                              '2013-01-01')
                                                     AND     DATEADD(year, -1,
                                                              '2013-10-01') )
        OR ( CONVERT(VARCHAR(10), i.sure_date, 120) BETWEEN '2013-01-01'
                                                    AND     '2013-10-01' )

语句一:得出的结果为4000多条

SELECT  a.styleid
FROM    dbo.d_sked i
        INNER JOIN dbo.d_skedsub a ON a.skedid = i.skedid
        INNER JOIN ( SELECT j.styleid
    &nb