enter image description here I am trying to select only rounded numbers like 1,1000,100000,200000,4000 from a large data set I want to select all rows with amount starting with whole numbers 1,2,3,4,5,6,7,8,9 and zeros after or just the whole number itself without zeros after.
SELECT [INPUTTER]
,[OUR_REFERENCE]
,[TRANS_REFERENCE]
,[COMMON_REF]
,[RECID]
,[ACCOUNT_NUMBER]
,[TRANSACTION_CODE]
,[NARRATIVE]
,[AMOUNT_LCY]
,[AMOUNT_FCY]
,[VALUE_DATE]
,[BOOKING_DATE]
,[CURRENCY]
,[EXCHANGE_RATE]
,[PRODUCT_CATEGORY]
,[PL_CATEGORY]
,[REVERSAL_MARKER]
FROM [Steward].[dbo].[vwSTMT_01]
v
where AMOUNT_LCY LIKE '[1-9]%' and AMOUNT_LCY NOT LIKE '[1-9]%[^0]';
https://drive.google.com/file/d/1KEhEVI_y9ANDQdMF2oGaduyZmHr4zNcL/view?usp=share_link
2条答案
按热度按时间csbfibhn1#
Seems like you could use a couple of
LIKE
expressions here. First you can useLIKE '[1-9]%'
to get only get rows that start with a numerical character (I assume they can't start with a0
but you can add that), and thenNOT LIKE '[1-9]%[^0]'
to exclude any rows that have a character that isn't a0
after the first digit:mznpcxlj2#
You could parse it to a decimal and check if it has a fractional part using modulo.