I have a journal type table where it has Account, Credit_Debit and Amount columns. I am trying a
select where by the result should look like a row followed by its contra amount row. Amount column is Numeric/Decimal.
Expected output: An amount followed by its equivalent opposite(plus or minus) amount
expected output
|Account|c_d|Amount|
| 1 |D | 100 |
! 7 |C | -100 |
| 8 |D | 750 |
| 1 |C | -750 |
| 10 |C | -500 |
| 11 |D | 500 |
So, my query below threw invalid relational operator
select * from table where amount between 100 and 1000 AND (-100) - (-1000)
This one returned empty result set
select * from table where
(amount between('100') AND ('1000')) AND (amount between('-100') AND ('-1000'))
ANDin middle of theamountstatements toOR.between('100') AND ('1000'))is really bad coding style. First numbers should not be enclosed in single quotes.'100'is a character literal (aka "string"), not a number.100is a number literal. Secondly: the parentheses around the numbers('-100')useless.