Untitled

example1
 avatar
user_0223141589
mysql
2 years ago
552 B
0
Indexable
Never
select
mp.NAME,
mp.CREATE_DATE,
wo.id,
rp.name,
COUNT(mwp.USER_ID),
count(wo.id)

from BIZ.DBT_STG.STG_ODOO_PROD__MRP_WORKORDER wo
join BIZ.DBT_STG.STG_ODOO_PROD__MRP_WORKCENTER_PRODUCTIVITY mwp on mwp.WORKORDER_ID = wo.id
join BIZ.DBT_STG.STG_ODOO_PROD__MRP_PRODUCTION mp on mp.id = wo.PRODUCTION_ID
join BIZ.DBT_STG.STG_ODOO_PROD__RES_USERS ru on ru.id = mwp.USER_ID
join BIZ.DBT_STG.STG_ODOO_PROD__RES_PARTNER rp on rp.id = ru.PARTNER_ID
where mp.CREATE_DATE > '2023-03-01 00:00:00'
group by 1,2,3,4

hAVING COUNT(MWP.USER_ID) > 1
order by 2 desc