select case when Zakaz __PrizPerevozki then Грузовая else Пассажиская

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
select
case when Zakaz.__PrizPerevozki = 'Г' then 'Грузовая' else 'Пассажиская' end as Тип,
Zakaz.NDokumenta as "Код Подразделения",
Zakaz.Recv as Номер,
Zakaz.Data10 as "Дата заказа",
Zakaz.Data8 as "Дата перевозки",
SprRab.NameAn as Заказчик,
SprPodr.NameAn as Позразделение,
SprEmployee.NameAn as Ответственный,
case when ISNULL(Zakaz.__LongString6, '')<> '' then Spr__PlaceLoadUnload.NameAn + ' / ' + Zakaz.__LongString6 else Spr__PlaceLoadUnload.NameAn end as "Место погрузки",
case when ISNULL(Zakaz.__LongString7, '')<> '' then Spr__PlaceLoadUnload2.NameAn + ' / ' + Zakaz.__LongString7 else Spr__PlaceLoadUnload2.NameAn end as "Место разгрузки",
SprVidGruz.NameAn as "Вид груза",
SprVesGruz.NameAn as "Вес груза",
Zakaz.SectionType as "Кол-во рейсов",
SprSposobPogr.NameAn as "Способ погрузки",
Zakaz.SysCode as "Время погрузки", --для 'Г'
Zakaz.__NameAn as "Время выезда", -- для 'П'
case when ISNULL(Spr__CityForZakaz.NameAn, '')<> '' then Spr__CityForZakaz.NameAn + ' / ' + Zakaz.LongString2 else Spr__CityForZakaz.NameAn end as "Пунк выезда",
case when ISNULL(Spr__CityForZakaz2.NameAn, '')<> '' then Spr__CityForZakaz2.NameAn + ' / ' + Zakaz.LongString4 else Spr__CityForZakaz2.NameAn end as "Пунк прибытия",
Zakaz.IntNumber3 as "Кол-во пассажиров",
Zakaz.LongString3 as "ФИО пассажиров",
Zakaz.LongString4000 as Примечание,
SprStatus.NameAn as "Статус",
SprPol.NameAn as "Автор карточки",
Zakaz.__LongString9 as "Номер машины",
Zakaz.__LongString8 as "Водитель",
Zakaz.__LongString10 as "телефон",
Zakaz.__LongString11 as "Дата и время подачи",
Zakaz.__LongString12 as "Дата и время окончания"
from MBAnalit Zakaz
join MBAnalitSpr SprRab on Zakaz.FIO = SprRab.Analit
join MBAnalitSpr SprPodr on Zakaz.Podr = SprPodr.Analit
join MBAnalitSpr SprEmployee on Zakaz.Employee = SprEmployee.Analit
join MBAnalitSpr SprStatus on Zakaz.__Status_ZakazForAut = SprStatus.Analit
join MBAnalitSpr SprPol on Zakaz.Polzovatel = SprPol.Analit
left join MBAnalitSpr Spr__PlaceLoadUnload on Zakaz.__PlaceLoadUnload = Spr__PlaceLoadUnload.Analit
left join MBAnalitSpr Spr__PlaceLoadUnload2 on Zakaz.__PlaceLoadUnload2 = Spr__PlaceLoadUnload2.Analit
left join MBAnalitSpr SprVidGruz on Zakaz.__VidGruz = SprVidGruz.Analit
left join MBAnalitSpr SprVesGruz on Zakaz.__VesGruz = SprVesGruz.Analit
left join MBAnalitSpr SprSposobPogr on Zakaz.__SposobPogr = SprSposobPogr.Analit
left join MBAnalitSpr Spr__CityForZakaz on Zakaz.__CityForZakaz = Spr__CityForZakaz.Analit
left join MBAnalitSpr Spr__CityForZakaz2 on Zakaz.__CityForZakaz2 = Spr__CityForZakaz2.Analit
where Zakaz.Vid = 3830