Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select Code, Name, Description, BarCode2, PriceOut2, RIGHT(GG, LEN(GG)-4) from (
- select T1.Code, T1.Name, T1.Description, T1.BarCode2, T1.PriceOut2,
- case
- when BarCode3 Like '%web0%' then '00. Специальное предложение'
- when BarCode3 Like '%web2%' then '90. Соусы'
- when BarCode3 Like '%web3%' then '91. Одноразовая посуда'
- else GoodsGroups.name
- end as GG, T1.BarCode3
- from (select Goods.Code,Goods.Name,Goods.BarCode2, Goods.Description, Goods.PriceOut2, Substring(GoodsGroups.Code,1,3) as a1, BarCode3
- from Goods left join GoodsGroups ON Goods.GroupID = GoodsGroups.ID
- where Goods.ID in ( select GoodID
- from Operations left join Goods ON Operations.GoodID = Goods.ID
- where ObjectID = 4 and OperType = 7 and
- (Goods.BarCode3 Like '%web%') and
- datediff(DAY, [dbo].[Operations].Date, CURRENT_TIMESTAMP) = 0 )
- or Goods.ID in ( select ID from Goods where (BarCode3 Like '%web0%') or (BarCode3 Like '%web2%') or (BarCode3 Like '%web3%') )
- ) as T1 left join GoodsGroups ON (a1 LIKE GoodsGroups.Code) ) as T2
- order by GG, Name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement