我在OBIEE中有一个查询,它提供以下结果集。
是否有可能在最后一列中为每个相同的电话号码显示1到N.这意味着我们将在最后一列中使用2,2,2,2,1,1,6,6,6,6,6,6而不是2,2,2,2,1,1,6,6,6,6,6,6 1,2,1,2,1,1,1,2,3,4,5,6
我在这里遇到心理障碍。用于生成提到的查询的SQL是:
SELECT "service request"."SR #" saw_0,
"- contact communication"."Mobile Phone #" saw_1,
Count("- contact communication"."Mobile Phone #") saw_2
FROM "service requests"
WHERE ( "service request dealer"."Local Dealer Number" = '20536' )
AND ( "- contact communication"."Mobile Phone #" IS NOT NULL )
GROUP BY saw_1
ORDER BY saw_1
我不介意修改上述查询或将其与其他查询组合或加入。请帮忙。
答案 0 :(得分:1)
试试这个:
SELECT *,
ROW_NUMBER()
OVER (
partition BY mobilephone
ORDER BY sr )
FROM yourtable
答案 1 :(得分:0)
试试这个:
SELECT "service request"."SR #" saw_0,
"- contact communication"."Mobile Phone #" saw_1,
row_number() over(partition by "- contact communication"."Mobile Phone #"
order by "service request"."SR #") saw_2
FROM "service requests"
WHERE ( "service request dealer"."Local Dealer Number" = '20536' )
AND ( "- contact communication"."Mobile Phone #" IS NOT NULL )
ORDER BY saw_1
答案 2 :(得分:0)
尝试使用列公式添加列:
rcount("- contact communication"."Mobile Phone #" by "service request"."SR #")
这应该为您提供手机号码的运行计数,按SR#分组。