create table bunker_calc_line(
voy number,
ship_code number,
grade varchar2(8),
bunk_line_type varchar2(4),
calc_status number
)
Table created.
insert into bunker_calc_line values (201717,427,'LS-380','80',0)
1 row(s) inserted.
insert into bunker_calc_line values (201717,427,'LS-380','80',2)
1 row(s) inserted.
select * from bunker_calc_line
VOY | SHIP_CODE | GRADE | BUNK_LINE_TYPE | CALC_STATUS | 201717 | 427 | LS-380 | 80 | 0 | 201717 | 427 | LS-380 | 80 | 2 |
---|
select bunk.*, dense_rank() over (partition by voy, ship_code, grade, bunk_line_type order by calc_status) ranking
from bunker_calc_line bunk
where (bunk.VOY = 201717 and bunk.SHIP_CODE = 427 or bunk.VOY = 201801 and bunk.SHIP_CODE = 351)
and bunk.GRADE = 'LS-380' and bunk.BUNK_LINE_TYPE = '80'
order by bunk.VOY desc, bunk.SHIP_CODE asc
VOY | SHIP_CODE | GRADE | BUNK_LINE_TYPE | CALC_STATUS | RANKING | 201717 | 427 | LS-380 | 80 | 2 | 2 | 201717 | 427 | LS-380 | 80 | 0 | 1 |
---|
select voy, ship_code, grade, bunk_line_type, calc_status from (
select bunk.*, dense_rank() over (order by calc_status) ranking
from bunker_calc_line bunk
where (bunk.VOY = 201717 and bunk.SHIP_CODE = 427 or bunk.VOY = 201801 and bunk.SHIP_CODE = 351)
and bunk.GRADE = 'LS-380' and bunk.BUNK_LINE_TYPE = '80'
)
where ranking = 1
order by VOY desc, SHIP_CODE asc
VOY | SHIP_CODE | GRADE | BUNK_LINE_TYPE | CALC_STATUS | 201717 | 427 | LS-380 | 80 | 0 |
---|
insert into bunker_calc_line values (201717,427,'LS-390','80',2)
1 row(s) inserted.
select voy, ship_code, grade, bunk_line_type, calc_status from (
select bunk.*, dense_rank() over (partition by voy, ship_code, grade, bunk_line_type order by calc_status) ranking
from bunker_calc_line bunk
where (bunk.VOY = 201717 and bunk.SHIP_CODE = 427 or bunk.VOY = 201801 and bunk.SHIP_CODE = 351)
and bunk.GRADE = 'LS-390' and bunk.BUNK_LINE_TYPE = '80'
)
where ranking = 1
order by VOY desc, SHIP_CODE asc
VOY | SHIP_CODE | GRADE | BUNK_LINE_TYPE | CALC_STATUS | 201717 | 427 | LS-390 | 80 | 2 |
---|
select voy, ship_code, grade, bunk_line_type, calc_status from (
select bunk.*, dense_rank() over (partition by voy, ship_code, grade, bunk_line_type order by calc_status) ranking
from bunker_calc_line bunk
where (bunk.VOY = 201717 and bunk.SHIP_CODE = 427 or bunk.VOY = 201801 and bunk.SHIP_CODE = 351)
and bunk.BUNK_LINE_TYPE = '80'
)
where ranking = 1
order by VOY desc, SHIP_CODE asc
VOY | SHIP_CODE | GRADE | BUNK_LINE_TYPE | CALC_STATUS | 201717 | 427 | LS-390 | 80 | 2 | 201717 | 427 | LS-380 | 80 | 0 |
---|