我有一个这样的 oracle 表。
我想在选择语句中获取格式为 Mon-YY/唯一编号的自定义唯一 ID
结果看起来像(参见 UNIQUEORDERID 列)
是否可以在 select 语句中实现结果?请帮我写查询。
谢谢,萨贾德
试试这个 -
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;
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;
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;