KakiJanaky Posted June 7, 2018 Report Posted June 7, 2018 please help, oracle sql lo ela format cheyyali column ni: If the dollar amount is $125 for total charges, then it should display with a 7 digit number padded with leading zeroes followed by 2 decimal places and the sign (+/-). For eg: --> If amount is $125, then 000012500+ --> If amount is -$155, then 000015500- Quote
teluguraja Posted June 7, 2018 Report Posted June 7, 2018 select statement lo idhi padeyyi lpad(coulm_name, 7, '0') || decode(sign(column_name), -1, '-', 1, '+', ' ') final_value Quote
KakiJanaky Posted June 7, 2018 Author Report Posted June 7, 2018 4 minutes ago, teluguraja said: select statement lo idhi padeyyi lpad(coulm_name, 7, '0') || decode(sign(column_name), -1, '-', 1, '+', ' ') final_value what's this? Quote
Lakhan Posted June 7, 2018 Report Posted June 7, 2018 2 minutes ago, KakiJanaky said: what's this? iPad kadu LPad adhi Quote
teluguraja Posted June 7, 2018 Report Posted June 7, 2018 1 minute ago, Lakhan said: iPad kadu LPad adhi adhi kooda cheppala Quote
CheGuevara Posted June 7, 2018 Report Posted June 7, 2018 25 minutes ago, KakiJanaky said: please help, oracle sql lo ela format cheyyali column ni: If the dollar amount is $125 for total charges, then it should display with a 7 digit number padded with leading zeroes followed by 2 decimal places and the sign (+/-). For eg: --> If amount is $125, then 000012500+ --> If amount is -$155, then 000015500- Does the dollar amount always be in hundreds? If the amount Differs which is other than hundres, then tou still want the format to be seven digit? If yes how should the padding of zeroes differs in the front and at the back for each differed amount? Quote
KakiJanaky Posted June 7, 2018 Author Report Posted June 7, 2018 33 minutes ago, teluguraja said: select statement lo idhi padeyyi lpad(coulm_name, 7, '0') || decode(sign(column_name), -1, '-', 1, '+', ' ') final_value 7 digit number padded with leading zeroes followed by 2 decimal places and the sign (+/-). It worked for 7 digits and sign but, When the amount is 653.8, final value displays as 00653.8+ which is not what I want. It should display 000065380+. 7 digits total along with 2 decimal places and a sign. Quote
KakiJanaky Posted June 7, 2018 Author Report Posted June 7, 2018 2 minutes ago, CheGuevara said: Does the dollar amount always be in hundreds? If the amount Differs which is other than hundres, then tou still want the format to be seven digit? If yes how should the padding of zeroes differs in the front and at the back for each differed amount? ,correct, the amount varies, it can be any number. Ultimately, the final value should be 7 digits (coz it cant be more than 7 digits) and 2 zeros for decimal replacement and sign. Quote
Satabdi Posted June 7, 2018 Report Posted June 7, 2018 18 minutes ago, Lakhan said: iPad kadu LPad adhi Ipad lo work chesthe alav rayali code nuvvu ukovayya Quote
KakiJanaky Posted June 7, 2018 Author Report Posted June 7, 2018 in sql server, i can do this, but not in oracle. also no privileges to create temp tables declare @amt as decimal(9,2) = -125.05 SELECT Convert(varchar(9),convert(bigint,abs(@amt)*100)) as amount ,@amt as amount_numeric into #temp select right('0000000000'+amount, 9) + case when amount_numeric >=0 then '+' else '-' end ,amount_numeric from #temp drop table #temp Quote
prabhu_pramod Posted June 23, 2018 Report Posted June 23, 2018 SELECT CASE WHEN y >= 0 THEN Lpad(To_char(y * 100), 9, 0) ||'+' ELSE Lpad(To_char(Abs(y * 100)), 9, 0) ||'-' END z FROM (SELECT -125.25 y FROM dual); Change the Y to your column Quote
kingcasanova Posted June 23, 2018 Report Posted June 23, 2018 On 08/06/2018 at 2:21 AM, KakiJanaky said: in sql server, i can do this, but not in oracle. also no privileges to create temp tables declare @amt as decimal(9,2) = -125.05 SELECT Convert(varchar(9),convert(bigint,abs(@amt)*100)) as amount ,@amt as amount_numeric into #temp select right('0000000000'+amount, 9) + case when amount_numeric >=0 then '+' else '-' end ,amount_numeric from #temp drop table #temp 3 decimal value isthe theda koduthundemo? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.