Answer the question
In order to leave comments, you need to log in
How to fix "out of memory" error in FastReport 4?
SELECT t.ВЛАДЕЛЕЦ_ВАГОНА, t.ВСЕГО, t.НА_ПРОСТОЕ, t.БЕЗ_ПРОСТОЯ, t.ПВ, t.СПЦ, t.ПЛ, t.ЦС,t.КР, t.ПРОЧИЕ FROM
(
SELECT
(
SELECT ro.ORGSHORTNAME FROM DK.RM_ORG ro WHERE ro.ID = rsd.CAROWNER
)
AS ВЛАДЕЛЕЦ_ВАГОНА,
(
SELECT count(*) FROM SALES.RM_SHEET_DETAIL rsd1 WHERE rsd1.CAROWNER = rsd.CAROWNER
)
AS ВСЕГО,
(
SELECT count(*) FROM SALES.RM_SHEET_DETAIL rsd1 WHERE rsd1.CAROWNER = rsd.CAROWNER AND rsd1.CARACCEPTED = 1
)
AS НА_ПРОСТОЕ,
(
SELECT count(*) FROM SALES.RM_SHEET_DETAIL rsd1 WHERE rsd1.CAROWNER = rsd.CAROWNER AND rsd1.CARACCEPTED = 0
)
AS БЕЗ_ПРОСТОЯ,
CASE rsd.CARTYPE
WHEN 263 THEN '1'
WHEN 60 THEN '1'
WHEN 265 THEN '1'
WHEN 206 THEN '2'
WHEN 205 THEN '2'
WHEN 50 THEN '50'
WHEN 70 THEN '70'
WHEN 40 THEN '40'
ELSE 'OTHERS'
END AS CARTYPE
FROM
SALES.RM_SHEET_DETAIL rsd
LEFT JOIN
SALES.E_NSI_WAG_TYPE e_nwt ON (e_nwt.WAG_TYPE_ID = rsd.CARTYPE)
)
PIVOT
(
count(CARTYPE) FOR CARTYPE IN( 1 AS ПВ, 2 AS СПЦ, 50 AS ПЛ, 70 AS ЦС, 40 AS КР, 'OTHERS' AS ПРОЧИЕ)
) t
Answer the question
In order to leave comments, you need to log in
In the context of the issued SQL query, of course, it is difficult to imagine what could be wrong, you would at least say how many hundreds or thousands of records it produces.
First try setting UniDirectional to true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question