-2
I’m having a problem in a sub-sale that returns me the payment type (CREDIT OR DEBIT) and whether the payment was in card or not.
However, if I have a payment with the two types of card the subconsulta will return two records and will end up breaking, what I could do for when I have two types of payment I consider only one, in my case I wanted to consider only credit.
I consider commissions through the type of payment; CREDIT + DEBIT = CREDIT (I want to assemble a case if one of the types was credit he consider only credit as type of payment)
follow what I did:
CASE
WHEN X.cartao = 'S' AND X.tipo = 'CREDITO' THEN 'CREDITO'
WHEN X.cartao = 'S' AND X.tipo = 'DEBITO' THEN 'DEBITO'
WHEN X.cartao = 'S' AND X.tipo = 'CREDITO' AND X.tipo = 'DEBITO' THEN 'CREDITO' --
ELSE 'N' END cartao,
Include your
SQL
, only hisCASE
doesn’t make any sense.– Bruno Warmling
It is impossible that
X.tipo = 'CREDITO'
andX.tipo = 'DEBITO'
simultaneously and therefore this third condition will never be satisfied. Since you haven’t explained enough how your data is organized maybe there can be multiple rows in your table, one for each card?– anonimo