MySQL Forums
Forum List  »  Italian

Sottazione aggregata tra due tabelle
Posted by: serenella angelilli
Date: September 26, 2021 01:00AM

Buogniorno ho due tabelle diverse devo sottrarre dei dati e mantenere l'aggregazione, vi posto le due select distinte che funzionano:

SELECT cont.policy_code AS NUMERO_POLIZZA, cont.output_type AS AZIONE ,
COUNT(cont.output_type) AS totale
FROM contab cont
GROUP BY cont.policy_code
order by cont.policy_code

select NPOL AS NUMERO_POLIZZA, AZIONE, count(AZIONE) AS TOTALE
from altea_20210921_duplicati_esclusi
GROUP BY NPOL

Il problema è che devo unire le due select e fare in modo che i dati della seconda select vengano sottratti ai dati della prima mantenendo la struttura della prima nella select di ritorno.

Grazie in anticipo a chi potrà aiutarmi.

Options: ReplyQuote


Subject
Views
Written By
Posted
Sottazione aggregata tra due tabelle
401
September 26, 2021 01:00AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.