select MC.STCODE,MC.STNAME,SUM(MC.TOTAL) TOTAL,'非周末'
       from MC_SDRPTSXS MC,FASOLARTOLUNAR FA
      where MC.FILDATE=FA.SOLARDATE AND exists (select 1
               from store
              where store.countries = '中国香港'  AND CODE LIKE /*VSTCODE ||*/ '000871%'
                and MC.stgid = gid)
                and fildate>='2016-03-06'
                and fildate<'2016-03-17'
                AND FA.WEEK not IN ('星期六','星期日')
                GROUP BY MC.STCODE,MC.STNAME

select MC.STCODE,MC.STNAME,SUM(MC.TOTAL) TOTAL,'非周末'
       from MC_SDRPTSXS MC,FASOLARTOLUNAR FA,store
      where MC.FILDATE=FA.SOLARDATE AND  store.countries = '中国香港'  AND CODE LIKE /*VSTCODE ||*/ '000871%'
                and MC.stgid = gid
                and fildate>='2016-03-06'
                and fildate<'2016-03-17'
                AND FA.WEEK not IN ('星期六','星期日')
                GROUP BY MC.STCODE,MC.STNAME
这两个有啥不一样,那个更好点?

解决方案 »

  1.   

    这种情况下:select 0 , 
    select 1,
    select *,
    select PK都一样,不用过于关注这些;
      

  2.   

    select 1 from mytable;与select anycol(目的表集合中的任意一行) from mytable;与select * from mytable 作用上来说是没有差别的,都是查看是否有记录,一般是作条件用的。select 1 from 中的1是一常量,查到的所有行的值都是它,但从效率上来说,1>anycol>*,因为不用查字典表。
      

  3.   

    1、select 1 from mytable;与select anycol(目的表集合中的任意一行) from mytable;与select * from mytable 作用上来说是没有差别的,都是查看是否有记录,一般是作条件用的。select 1 from 中的1是一常量,查到的所有行的值都是它,但从效率上来说,1>anycol>*,因为不用查字典表。