Home > database >  This statement of how to convert a novice to understand
This statement of how to convert a novice to understand

Time:09-19

Declare @ sql2 varchar (8000)
The Set @ sql2='select shopcode'
Select @ sql2=@ sql2 + ', the sum (case giftcode when ' ' '+ giftcode +' ' 'then qty_LD else 0 end) [' + giftcode +' _yesterday], the sum (case giftcode when ' ' '+ giftcode +' ' 'then qty else 0 end) [' + giftcode +' _LTD] '
The from (select distinct giftcode from # gift) as cj - the names of all the subjects listed
Select @ sql2=@ sql2 + 'into test2.. Buy_get_data_byshop from # data group by shopcode '
The Exec (@ sql2)


Could you tell me how to translate the statements into general, simple SQL statement
This statement is listed turned
  • Related