Запись count (1) с использованием определенных имен столбцов после / до ранга - PullRequest
0 голосов
/ 26 октября 2018

Таблица 1: Используя приведенный ниже запрос, я получаю столбцы с Рангом, не получая счет

SELECT *
FROM (SELECT b.market,  a.WONAME, a.STATUS,a.DOCUMENTYPE  as build_stage, 'CORE' as DESIGN_TYPE, '1.0' as GRP_VERSION,
rank() over (partition by woname, a.DOCUMENTYPE order by a.REQUESTTIME desc) rnk
FROM batch_files a,  BATCH_FILE_UPLOAD_REQUEST b where TO_DATE (a.REQUESTTIME) < TO_DATE ('24-OCT-18') 
and TO_DATE (a.REQUESTTIME) > TO_DATE ('01-JUL-18')
and a.BATCHID=b.BATCHID)
WHERE rnk = 1
UNION
SELECT *
FROM (SELECT b.market, a.WONAME, a.STATUS,a.DOCUMENTYPE  as build_stage, a.DESIGN_TYPE, a.GRP_VERSION,
rank() over (partition by woname, a.DOCUMENTYPE order by a.REQUESTTIME desc) rnk
FROM BATCH_FILES_V2 a,  BATCH_FILE_UPLOAD_REQ_V2 b where TO_DATE (a.REQUESTTIME) < TO_DATE ('24-OCT-18') 
and TO_DATE (a.REQUESTTIME) > TO_DATE ('01-JUL-18')
and a.BATCHID=b.BATCHID)
WHERE rnk = 1 ;

Таблица 2: Используя приведенный ниже запрос, я получаю счет, но не Ранг

select b.market, a.WONAME,a.DOCUMENTYPE as build_stage, 'CORE' as DESIGN_TYPE, '1.0' as GRP_VERSION, 
count(1) from BATCH_FILES a, BATCH_FILE_UPLOAD_REQUEST b
where TO_DATE (a.REQUESTTIME) < TO_DATE ('24-OCT-18') and TO_DATE (a.REQUESTTIME) > TO_DATE ('01-JUL-18')
and a.BATCHID=b.BATCHID
group by b.market,  a.WONAME, a.DOCUMENTYPE
union
select d.market, c.WONAME,c.DOCUMENTYPE as build_stage,  c.DESIGN_TYPE ,c.GRP_VERSION, 
count(1) from BATCH_FILES_V2 c, BATCH_FILE_UPLOAD_REQ_V2 d
where TO_DATE (c.REQUESTTIME) < TO_DATE ('24-OCT-18') and TO_DATE (c.REQUESTTIME) > TO_DATE ('01-JUL-18')
and c.BATCHID=d.BATCHID
group by d.market, c.WONAME,c.DOCUMENTYPE, c.DESIGN_TYPE, c.GRP_VERSION;

Я хочу объединить таблицу 1 с таблицей 2, и мне нужно отобразить один запрос с market, woname, status, build_stage, Design_type, GRP_version & Rank.

Я использую PLSQL.Заранее спасибо

...