Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.06 KB | None | 0 0
  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 GoodsGroups.name
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement