Netezza SQL函数

时间:2016-07-14 16:15:36

标签: netezza

我想在Netezza中按照以下标准选择数据。 有人可以帮我写sql。

Case 1: Unique ID has 2 "."s 
Deal ID  = Parse  from UNIQ_ID. Pos 1 to first "."
E.g. 
Unique ID = 0000149844.FXFWD.COIBI_I
Deal ID = 0000149844

Case 2: Unique ID has 1 "."s 
Deal ID  = Parse  from UNIQ_ID. First "." to end
E.g
Unique ID = 25808.1234140AT`enter code here`
Deal ID = 1234140AT   

1 个答案:

答案 0 :(得分:0)

使用"位置" Netezza的功能来确定"的位置。",在" substr"中使用此输出。用于提取必填字段的功能。

案例1:

select substr('0000149844.FXFWD.COIBI_I',1,(position('.' in '0000149844.FXFWD.COIBI_I') - 1));

案例2:

select substr('25808.1234140AT',(position('.' in '25808.1234140AT') + 1));