select ZSGiftSignIn_m.ZStart_Date,sum(zqty) as zqty into 一个表 from ZSGiftSignIn_d,ZSGiftSignIn_m where ZSGiftSignIn_d.ZGift_ID in (select ZGift_ID from ZSGiftInfo where zGift_Category='白金卡')and ZSGiftSignIn_m.ZVouch_ID=ZSGiftSignIn_d.ZVouch_ID and ZSGiftSignIn_d.ZScore_ID in (select ZScore_ID from ZSMemberInfo)and ZSGiftSignIn_m.ZStart_Date between @data and @data2 and ZSGiftSignIn_d.ZGift_ID in (select ZGift_ID from ZSGiftInfo )group by ZSGiftSignIn_m.ZStart_Date

解决方案 »

  1.   

    The SELECT INTO statement retrieves one row of results. The SELECT INTO statement is also known as a singleton SELECT statement.Syntax
    SELECT [select_list] INTO {:hvar [,...]} select_options---------------------------------
    select ZSGiftSignIn_m.ZStart_Date,sum(zqty) as zqty into [tablename] from 
                                                        ~~~~~~~~~~~~~~~~
      

  2.   

    insert 目标表(ZStart_Date,count)--这里目标表必须存在
    select ZSGiftSignIn_m.ZStart_Date,sum(zqty) from ZSGiftSignIn_d,ZSGiftSignIn_m where ZSGiftSignIn_d.ZGift_ID in (select ZGift_ID from ZSGiftInfo where zGift_Category='白金卡')and ZSGiftSignIn_m.ZVouch_ID=ZSGiftSignIn_d.ZVouch_ID and ZSGiftSignIn_d.ZScore_ID in (select ZScore_ID from ZSMemberInfo)and ZSGiftSignIn_m.ZStart_Date between @data and @data2 and ZSGiftSignIn_d.ZGift_ID in (select ZGift_ID from ZSGiftInfo )group by ZSGiftSignIn_m.ZStart_Date