a guest Sep 20th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. select Code, Name, Description, BarCode2, PriceOut2, RIGHT(GG, LEN(GG)-4) from (
  2. select T1.Code, T1.Name, T1.Description, T1.BarCode2, T1.PriceOut2,
  3. case
  4. when BarCode3 Like '%web0%' then '00. Специальное предложение'
  5. when BarCode3 Like '%web2%' then '90. Соусы'
  6. when BarCode3 Like '%web3%' then '91. Одноразовая посуда'
  7. else
  8. end as GG, T1.BarCode3
  9. from  (select Goods.Code,Goods.Name,Goods.BarCode2, Goods.Description,  Goods.PriceOut2, Substring(GoodsGroups.Code,1,3) as a1, BarCode3
  10. from Goods left join GoodsGroups ON Goods.GroupID = GoodsGroups.ID
  11. where Goods.ID in ( select GoodID
  12. from Operations left join Goods ON Operations.GoodID = Goods.ID
  13. where ObjectID = 4 and OperType = 7 and
  14. (Goods.BarCode3 Like '%web%') and
  15. datediff(DAY, [dbo].[Operations].Date, CURRENT_TIMESTAMP) = 0 )
  16. or Goods.ID in ( select ID from Goods where (BarCode3 Like '%web0%') or (BarCode3 Like '%web2%') or (BarCode3 Like '%web3%') )
  17. ) as T1 left join GoodsGroups ON (a1 LIKE GoodsGroups.Code) ) as T2
  18. order by GG, Name
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand