Home > database >  How to find out difference between SQL numerical accords with a condition
How to find out difference between SQL numerical accords with a condition

Time:12-31

Such as a table with three records worth 100, 100, - how to find out the second 100-100?

A query is to find a negative number, but you can't have the same values of positive and two negative results, in turn, and an equivalent amount of positive match, this is wrong

CodePudding user response:

Using the ranking function, rownumer () over (order by)

CodePudding user response:

Can you write the detailed point? My statement is that
The select p. ayment_id,
E.e mpee_acct,
E.e mpee_name,
, dc ode_name,
B.d eposit_amount/100 as charge,
To_char (f.a ccount_name) as prod_inst_name,
F.a ccount_number,
G.a cc_nbr,
P. ayment_date,
B.s taff_id
The from [email protected] B left join CRM. Tb_pty_code d on b.O PERATION_TYPE=, dc ode and, dc ode_type='OPE' left join CRM. Tb_pty_empee e on b.s taff_id=e.e mpee_id left join ogg. ACCOUNT_551 f on f.a ccount_id=b.a cct_id left join CRM. Prod_inst_551 g on g.p rod_inst_id=f.s erv_id
Where b.o bj_type='0' and e.e mpee_acct='71097401' and p. ayment_date & gt;=to_date (' 2020-12-22 ', '- DD YYYY - MM) and p. ayment_date & lt; (to_date (' 2020-12-22 ', '- DD YYYY - MM) + 1) and b.d eposit_amount & lt; 0
And not the exists (select * FROM [email protected] where deposit_amount=b.d eposit_amount * - 1
And pay_acct_id=p. ay_acct_id and staff_id=b.s taff_id and payment_date & gt;=to_date (' 2020-12-22 ', '- DD YYYY - MM) and payment_date & lt; (to_date (' 2020-12-22 ', '- DD YYYY - MM) + 1))

CodePudding user response:

Query is to find a negative number, but can't have the same values of positive and two negative results, in turn, and an equivalent amount of positive match, it's not

CodePudding user response:

Write the results you want and rules clearly

CodePudding user response:

Stick figure is and code corresponding?
B.d eposit_amount & lt; 0, figure in this field and greater than zero,

CodePudding user response:

Demand is found out according to the code of values, the b table deposit_amount cannot exist corresponding comes at a time?
  • Related