如何在Oracle查询中将sysdate连接到结果输出中

huangapple go评论49阅读模式
英文:

How to concatetante sysdate to result output in oracle query

问题

我对Oracle不太了解,作为项目的一部分,我尝试在我的SQL插入列中的序列ID生成器中添加或连接日期值。

生成序列号的查询是:

select nvl(max(RII_INDENT_ID_SL), 0) + 1 as ID from T_RAKE_INDENT_IBMD

该查询以整数形式输出,例如23、24等,作为序列号,它取最大值然后加1,从而创建新的序列号。

为了使它成为唯一的ID,我想要将sysdate的值,特别是年份和月份,添加到结果输出中。

所以结果会是这样的:

1-23/09/2022

通过连接操作符||可以实现吗?

英文:

I am new to oracle and as part of a project I was trying add or concatenate date value to serial id
generator in my sql insert column .

The query generating serial numbers is

select nvl(max(RII_INDENT_ID_SL),0 +1 ID from T_RAKE_INDENT_IBMD)

This query gives output in the form of integers like 23,24 etc as serial numbers taking the maximum value and adding 1 thus creating new serial no.

In order to make it a unique ID I want to add sysdate value particularly the year and month to the result output.

so the result will be something like this:

1-23/09/2022

Can it be done by concatenating || the sysdate value?

答案1

得分: 0

可以使用||运算符来完成:

select nvl(max(RII_INDENT_ID_SL), 0) + 1 || TO_CHAR(SYSDATE, 'DD/MM/YYYY') as ID 
from T_RAKE_INDENT_IBMD
英文:

Absolutely it could be done using || operator -

select nvl(max(RII_INDENT_ID_SL),0 +1 || TO_CHAR(SYSDATE, 'DD/MM/YYYY') ID 
  from T_RAKE_INDENT_IBMD)

huangapple
  • 本文由 发表于 2023年2月6日 21:49:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75362153.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定