Гость
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Ограничение по дате с участием @ReportDate / 1 сообщений из 1, страница 1 из 1
16.03.2021, 18:45
    #40054259
elay13
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Ограничение по дате с участием @ReportDate
Пытаюсь через dateadd и @ReportDate сделать ограничение по месяцу вместо использования appl_month. Подскажите как правильно это сделать.

Примерный запрос:

DECLARE @ReportDate date
SET @ReportDate = '01.09.2020'
select appl_month
, (sum(case when financed = 1 and appl_month = '2020-07' then app_PS_2mob end)
/ sum(case when financed = 1 and appl_month = '2020-07' then cash_to_client end))
/ cast((sum(case when financed = 1 and appl_month = '2020-07' then app_PS_1mob end)
/ sum(case when financed = 1 and appl_month = '2020-07' then cash_to_client end)) as float) as Рои2наРои1_07

, (sum(case when financed = 1 and appl_month = '2020-06' then app_PS_2mob end)
/ sum(case when financed = 1 and appl_month = '2020-06' then cash_to_client end))
/ cast((sum(case when financed = 1 and appl_month = '2020-06' then app_PS_1mob end)
/ sum(case when financed = 1 and appl_month = '2020-06' then cash_to_client end)) as float) as Рои2наРои1_06

from DWH
where date_time >= '01-01-2020'
and date_time <='12-31-2020'
group by appl_month
order by appl_month
...
Рейтинг: 0 / 0
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / Ограничение по дате с участием @ReportDate / 1 сообщений из 1, страница 1 из 1
Целевая тема:
Создать новую тему:
Автор:
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]