我可以在查询中单独对两列进行排序,以便两者都处于完美的加入顺序吗?
举例:
QUERY
select
ad.escore,
ad.mscore,
round(sum(ps.cnt) / sum(n.cnt) * 100,1) as percent
from
(
select
account_no,
to_char(trunc(empirica_score - 5, -1) + 5, '9999') || '-' || to_char(trunc(empirica_score - 5, -1) + 14, '9999') as escore,
cast(((mfin_score - 1) / 25) * 25 + 1 as text) || '-' || cast(((mfin_score - 1) / 25) * 25 + 25 as text) as mscore
from account_details
) ad
join
(
select custno, count(*) as cnt
from paysoft_results
where result = 'Successful'
and resultdate >= '13/08/2014'
and resultdate <= '12/19/2014'
group by custno
) ps on ps.custno = ad.account_no
join
(
select customer_code, count(distinct start_date) as cnt
from naedo
and start_date >= '13/08/2014'
and start_date <= '12/19/2014'
group by customer_code
) n on n.customer_code = ad.account_no
group by ad.escore, ad.mscore;
返回结果
报告网格
是否可以使列和行完全按升序排列?
答案 0 :(得分:1)
列和行实际上是在报表中排序的。您正在排序字符串值,其中&#39; 51-75&#39;比#101; 101-125&#39;更大,所以它看起来不对。
您需要格式化&#39; 75-75&#39; as&#39; 051-075&#39;使其按数字范围排序。