1

我有一个这样的 oracle 表。

在此处输入图像描述

我想在选择语句中获取格式为 Mon-YY/唯一编号的自定义唯一 ID

结果看起来像(参见 UNIQUEORDERID 列)

在此处输入图像描述

是否可以在 select 语句中实现结果?请帮我写查询。

谢谢,萨贾德

4

3 回答 3

2

试试这个 -

SELECT REQUEST_ID,
       NAME_OF_TRAINING,
       APPLIED_DATE,
       to_char(APPLIED_DATE,'MON-YY') || '/' || ROW_NUMBER over (partition by to_char(APPLIED_DATE,'MON-YY') order by to_char(APPLIED_DATE,'MON-YY')) AS UNIQUEORDERID
FROM tablename;
于 2012-05-21T08:11:12.087 回答
1
SELECT request_id,
       name_of_training,
       applied_date,
       to_char(applied_date,'MON-YY') || 
               '/' || 
               to_char(row_number() over (partition by to_char(applied_date,'MON-YY'), '000')
               ) AS UNIQUEORDERID
FROM tablename;
于 2012-05-21T08:24:44.617 回答
0
select a.*,to_char(a.applied_date,'MON-YY')||a.request_id UNIQUEORDERID
from table_name a; 

编辑 将此转换为您的数据

select object_name
,to_char(created,'MON-YY')||'/'||row_number() over (partition by to_char(created,'MON-YY') order by to_char(created,'MON-YY'))
from user_objects;
于 2012-05-21T08:07:04.893 回答