Сам Запрос: |Select |Docs.PrihRash as [ВидДвиженияПриходРасход], |Docs.VidOper as [ВидОперацииСТоваром], |Docs.Project as [Проект $Справочник.Проекты], |Docs.Org as [Организация $Справочник.Фирмы], |Docs.Sklad as [Склад $Справочник.Склады], |Docs.DataSklad as [ДатаОтчета], |Docs.Kontr as [Контрагент $Справочник.Контрагенты], |Docs.KontrSklad as [КонтрагентСклад $Справочник.Склады], |Docs.Nomenkl as [Номенклатура $Справочник.Номенклатура], |Sum(Docs.Kolvo) as [Количество], |Sum(Docs.Summa) as [Сумма] |From |( |Select -- ВводОстатковТМЦ |DocHeader.IdDoc as IdDoc, |'Приход' as PrihRash, |'НачальныйОстаток' as VidOper, |Journ.SP798 as Project, |Journ.SP4056 as Org, |DocHeader.SP3941 as Sklad, |cast('17530101' as DateTime) as DataSklad,//вот тут не понятно как //|'' as DataSklad, |'' as Kontr, |'' as KontrSklad, |DocTable.SP3944 as Nomenkl, |DocTable.SP3945 * Fenix_TD.dbo.fn_NotNull(DocTable.SP3947) as Kolvo, |DocTable.SP3948 as Summa |From |_1sjourn as Journ |inner join DH3957 as DocHeader on DocHeader.IdDoc = Journ.IdDoc |inner join DT3957 as DocTable on DocTable.IdDoc = Journ.IdDoc |Where Left(Journ.DATE_TIME_IDDOC,8) = '" + Формат(Источник,"ДГГГГММДД") + "' |And Journ.CLOSED = 1 |And DocHeader.SP3935 = ' 2Y7 ' -- Вид операции ОстаткиТМЦ
|Union All |Select -- ВыпускПродукции |DocHeader.IdDoc as IdDoc, |'Приход' as PrihRash, |'КупляПродажа' as VidOper, |Journ.SP798 as Project, |Journ.SP4056 as Org, |DocHeader.SP6883 as Sklad, |DocHeader.SP6887 as DataSklad, |'' as Kontr, |'' as KontrSklad, |DocTable.SP6889 as Nomenkl, |DocTable.SP6890 * Fenix_TD.dbo.fn_NotNull(DocTable.SP6892) as Kolvo, |DocTable.SP6894 * Fenix_TD.dbo.fn_NotNull(DocHeader.SP6885) as Summa |From |_1sjourn as Journ |inner join DH6898 as DocHeader on DocHeader.IdDoc = Journ.IdDoc |inner join DT6898 as DocTable on DocTable.IdDoc = Journ.IdDoc |Where Left(Journ.DATE_TIME_IDDOC,8) = '" + Формат(Источник,"ДГГГГММДД") + "' |And Journ.CLOSED = 1
|