我有一个firebird数据库和这个查询:
select distinct
case
when exists (select * from fixvar
where costtype_id=7 and extract(year from ct_from)<=2017 and
2017<=extract(year from ct_to) and costcenter_id=10)
then (select fix from fixvar where costtype_id=7 and extract(year from ct_from)<=2017 and
2017<=extract(year from ct_to) and costcenter_id=10)
else (select fix from fixvar where costtype_id=7 and extract(year from ct_from)<=2017 and
2017<=extract(year from ct_to))
end as fix,
case
when exists (select * from fixvar
where costtype_id=7 and extract(year from ct_from)<=2017 and
2017<=extract(year from ct_to) and costcenter_id=10)
then (select var from fixvar where costtype_id=7 and extract(year from ct_from)<=2017 and
2017<=extract(year from ct_to) and costcenter_id=10)
else (select var from fixvar where costtype_id=7 and extract(year from ct_from)<=2017 and
2017<=extract(year from ct_to) and costcenter_id=10)
end as var
from fixvar
我得到了正确的结果,但我可以做得更短吗?
我想要的是:我想查询字段fix
和var
。如果有一行costcenter_id
为10
,那么我想要有相应的fix
和var
值,如果没有,那么我们要避开的值不是costcenter_id
( - 1)。
编辑:
示例数据:
如您所见,有两行。所以,如果costcenter_id=10
存在一行,那么我想要appr。 fix
和var
值,如果此costcenter_id
没有行,那么我想要fix
和var
值,其中costcenter_id=-1
答案 0 :(得分:0)
我想,我有解决方案:
$('#prev').click(function () {
pageNumber--;
showPage(pageNumber);
if($('#more').prop('disabled')) {
$('#more').prop('disabled', false);
}
});
$('#more').click(function () {
pageNumber++;
showPage(pageNumber);
if($('#prev').prop('disabled')) {
$('#prev').prop('disabled', false);
}
});