select with while [message #681477] |
Wed, 22 July 2020 04:04 |
mape
Messages: 298 Registered: July 2006 Location: Slovakia
|
Senior Member |
|
|
Hello
I would like to get an advice.
create table xxx_mape_123
(month_key number , flag varchar2(10) )
insert into xxx_mape_123 values (202001, NULL);
insert into xxx_mape_123 values (202002, NULL);
insert into xxx_mape_123 values (202003, 'Y');
insert into xxx_mape_123 values (202004, NULL);
insert into xxx_mape_123 values (202005, NULL);
insert into xxx_mape_123 values (202006, 'Y/N');
insert into xxx_mape_123 values (202007, NULL);
insert into xxx_mape_123 values (202008, NULL);
select * from xxx_mape_123
order by month_key;
And I would like to write select where logic will be:
- when find not null FLAG (order by month_key) display next FLAG like you finded before
The result should be like this:
202001 NULL
202002 NULL
202003 Y
202004 Y
202005 Y
202007 Y/N
202008 Y/N
Does anybody know how to do that ??
Thanks a lot
Regards
MArtin
|
|
|
|
|
|
Re: select with while [message #681489 is a reply to message #681477] |
Wed, 22 July 2020 12:23 |
|
EdStevens
Messages: 1376 Registered: September 2013
|
Senior Member |
|
|
I would suggest that your MONTH_KEY be a DATE, not a NUMBER. You use may not care about day, hour, minute, and second, but you can always default them to day 1 and time zero. Hardly a week goes by that, on some oracle forum, someone will be searching for a solution to a problem that was self-inflicted by not using DATE to store dates.
|
|
|