.Extract Value from Vachar2 - sql

I want to extract value which are under double cotted ("D With GST"*"GST Rate"/100%).I need (D with GST) in one temporary column and GST Rate in another now its in a varchar2 attribute in SQl.
I need both or multiple value under double cotted separately. Thanks

Related

Shouldn't binary_double store a higher value than number in Oracle?

Considering the following test code :
CREATE TABLE binary_test (bin_float BINARY_FLOAT, bin_double BINARY_DOUBLE, NUM NUMBER);
INSERT INTO binary_test VALUES (4356267548.32345E+100, 4356267548.32345E+2+300, 4356267548.32345E+100);
SELECT CASE WHEN bin_double>to_binary_double(num) THEN 'Greater'
WHEN bin_double=to_binary_double(num) THEN 'Equal'
WHEN bin_double<to_binary_double(num) THEN 'Lower'
ELSE 'Unknown' END comparison,
A.*
FROM binary_test A;
I've tried to see which one stores higher values. If I try to add E+300 for the number and binary_float columns, it returns numeric overflow error. So, I thought I could store a greater value with the binary_float.
However, when I tried to check it, it shows a lower value, and with the case comparison it says it is lower too. Could you please elaborate this situation?
You are inserting the value 4356267548.32345E+2+300 into the binary double column. That evaluates to 4356267548.32345E+2, which is 435626754832.345, plus 300 - which is 435626755132.345 (or 4.35626755132345E+011, which becomes 4.3562675513234497E+011 when converted to binary double). That is clearly lower than 4356267548.32345E+100 (or 4.35626754832345E+109, which becomes 4.3562675483234496E+109 when converted to binary double).
Not directly relevant, but you should also be aware that you're providing a decimal number literal, which will be implicitly converted to binary double during insert. So you can't use 4356267548.32345E+300, as that is too large for the number data type. If you want to specify a binary double literal then you need to append a d to it, i.e. 4356267548.32345E+300d; but that is still too large.
The highest you can go with that numeric part is 4356267548.32345E+298d, which evaluates to 4.3562675483234498E+307 - just below the data type limit of 1.79769313486231E+308; and note the loss of precision.
db<>fiddle

I get this error: ORA-01438: value larger than specified precision allowed for this column

I have a column in my database table that is of type Number(5,3). I need to be able to insert data or update data to this column. I am currently using a form field that lets users input whatever number they want. This field is the one used when inserting or updating data into this column of type Number(5,3). When testing I enter any number and get this error: ORA-01438: value larger than specified precision allowed for this column
I am aware the data type NUMBER(5,3) means 5 is precision (total number of digits) and the 3 means scale (number of digits to the right of decimal point). For example: 52.904
Is there a function in oracle to format any number into a number of this type: NUMBER(5,3)?
Again I would like for the user to input any number on the field and be able to process that number as NUMBER(5,3) to insert or update into my table.
You could use something like this:
select cast (512.33333333 as number(5,2)) from dual;

What is a type of my value 675763582022462206:57 in sql creating data table query?

I am creating a table with several columns in sql:
CREATE TABLE.....
and one of them is going to have values like this: 675763582022462206:57. As you see it has : in it. So what is a type of it? Is it UInt16 or String?
It must be varchar or nvarchar in this case. The database doesn't recognize ":" as a part of a number, unless you say to Windows in advanced region settings that this is your decimal point. If you can store 57 (after ":") in a different column, then you can save the number before ":" as a bigint if you wish
This value can't be stored in a numeric type due to the colon (:), so you'll have to use one of the character types - i.e., a sufficiently long char or varchar.

Minimum length of double value in a column in Impala table

I am trying to find the minimum length by getting the length of each values in a column (double) in a table and running a min function on top of it to get the minimum length.
This works well when the column is a string type but the 'length' function does not work for double datatype in impala, what is the other way to address this?
min(length(columnname))
All double columns are 8 bytes, as explained in the documentation. LENGTH() is a string function and it doesn't really make sense on a numeric value (although you can convert to a string and then measure the length).

Extracting value from curly bracket SQL

I am trying figure out how to extract a value from curly brackets in a column in Prestosql.
The field looks like,
rates
{"B":750}
{"B":1600}
{"B":900}
I want to extract the number values only in each bracket.
Also, if I want to divide that by 10 and then divide by 20 would that be easy to add into the query?
The rates column is of type map(varchar, bigint).
Since rates column is of type map(varchar, bigint). You can use Presto Map Functions and Operators on it. Examples:
SELECT rates['B'] FROM ... -- value under key "B"
SELECT map_values(rates) FROM ... -- all values in a map
See more in the Presto documentation.
Use something like this, where the regexp_extract function pulls out the number from your string, and the cast function converts this from a string to a number, which you can then go on to divide by 10 etc.
select cast(regexp_extract(rates, '\d+') as double) / 10
from my_table