|
|
|
|
|
|
|
Re: split a number by slab [message #632993 is a reply to message #632957] |
Mon, 09 February 2015 17:09 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
Probably the easiest way would be to place the ranges into a table:
N LOW HIGH
- --- ----
1 1 5
2 6 9
3 10 9999
Then you can simply select from the table (untested code)
SELECT N, LEAST(¶m, HIGH) - LOW) + 1
FROM range_table
WHERE HIGH >= ¶m
If the ranges change each time you use them and you need to build them on the fly, then you could use a Nested Table Object that you load using a function / method, but this is a bit more complex.
Ross Leishman
|
|
|
Re: split a number by slab [message #633004 is a reply to message #632993] |
Tue, 10 February 2015 00:33 |
mahbbu
Messages: 6 Registered: August 2005
|
Junior Member |
|
|
Quote:Then you can simply select from the table (untested code)
Not working, anyway i'm focusing my topic in more brief way instead of short and snappy way.
it'll be great if anyone assist me to build an oracle query that
I have a table, Named as date_range_charge and example as follows
From_days | To_days | Charge
1 4 0
5 9 10
10 14 20
15 999 25
Now I will give two parameters in query like ¶m1= '10-JAN-2015' and ¶m2='25-JAN-2015'. based on 2 date parameters value and above table value the expected result will be:
Start_date | End_date | Days| Amount
10-JAN-2015 13-JAN-2015 4 0
14-JAN-2015 18-JAN-2015 5 50
19-JAN-2015 23-JAN-2015 5 100
24-JAN-2015 25-JAN-2015 2 50
-Regards
Mahbub Shohag
|
|
|
|
Re: split a number by slab [message #633008 is a reply to message #633005] |
Tue, 10 February 2015 02:33 |
mahbbu
Messages: 6 Registered: August 2005
|
Junior Member |
|
|
please assist me to build an oracle query for below expected result that
I have 2 tables, Named as **detention_charge_slot** and **detention_invoice** example as follows
create table detention_charge_slot
(slot_no number(5),
from_days number(10),
to_days number(10),
charge_amount number(10,2));
insert into detention_charge_slot
values (1,1,4,0);
insert into detention_charge_slot
values (2,5,9,10);
insert into detention_charge_slot
values (3,10,14,20);
insert into detention_charge_slot
values (4,15,999,25);
create table detention_invoice
(invoice_no number(10),
invoice_dt date,
delivery_dt date);
insert into detention_invoice
values(1,'10-JAN-2015','25-JAN-2015');
Expected result for invoice_no=1
Start_date | End_date | Days| Charge_Amount
10-JAN-2015 13-JAN-2015 4 0
14-JAN-2015 18-JAN-2015 5 10
19-JAN-2015 23-JAN-2015 5 20
24-JAN-2015 25-JAN-2015 2 25
|
|
|
|
|
|
|