MySQL Forums
Forum List  »  Italian

select di due campi nella stessa colonna
Posted by: serenella angelilli
Date: October 22, 2021 07:41AM

Salve volevo sapere se due campi si possono unire su una stessa colonna come output. mi spiego:

SELECT (cf.cf) AS subscriber_cf,
(r.cf) AS claims_cf,
g.refunds_type as claims_type,
YEAR(documents.doc_date) AS claims_year,
SUM(documents.amount) AS claims_amount,
SUM(payments.refund_amount) AS refunds_amount
FROM cg_hs_claims c
JOIN(
SELECT cd.claim_id,
MIN(is_hs) AS is_hs,
MIN(cd.doc_date) AS doc_date,
MIN(cd.doc_date) AS min_doc_date,
SUM(cdp.amount) AS amount
FROM cg_hs_claim_documents_payments cdp
JOIN cg_hs_claim_documents cd ON cd.id = cdp.document_id
GROUP BY claim_id
) documents ON documents.claim_id = c.id AND documents.is_hs = 0
JOIN(
SELECT claim_id,
SUM(refund_amount) AS refund_amount
FROM cg_hs_claim_payments
-- WHERE YEAR(payment_sent_date) = '" . $db->esc($year) . "'
GROUP BY claim_id
) payments ON payments.claim_id = c.id
JOIN cg_hs_guarantees g ON g.id = c.guarantee_id AND g.refunds_type != ' '
JOIN cg_hs_subscribers s ON s.id = c.subscriber_id
JOIN cg_hs_companies co ON co.id = s.company_id
JOIN cg_hs_cfs cf ON cf.id = s.cf_id
LEFT JOIN cg_hs_subscriber_relatives r ON r.id = c.relative_id
WHERE c.state > 0 AND co.group_id = 39
GROUP BY subscriber_cf, claims_year
ORDER BY subscriber_cf, claims_year;

in questa select in campo claims_cf dovrebbe incolonnarsi sotto subscriber_cf per quelli che sono i cf dei maggiorenni mentre i minorenni (da calcolare come condizione) possono rimanere dove sono....spero di essermi spiegata.
Grazie chi potrĂ  aiutarmi.

Options: ReplyQuote


Subject
Views
Written By
Posted
select di due campi nella stessa colonna
71
October 22, 2021 07:41AM


Sorry, only registered users may post in this forum.

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.