UPDATE SUM +1 to decimal

Asked

Viewed 392 times

2

I need to assemble a UPDATE in a table however, in the value field: '1481126826.2363343', I need this number to turn '1481126826.2363344'

To query that I’m trying and the next :

UPDATE callcenter.chamada_agente  
   SET uniqueid = SUM('1481126826.2363343'  + 1)
 WHERE id_chamada_agente  = 32408 
   AND tipo_chamada = 'MANUAL'
   AND datahora_inicio BETWEEN '2016-11-01 00:00:00' AND '2016-12-15 23:59:59';

Can you help me ?

  • 1

    And what’s the problem? error? or the number becomes a different than expected?

  • Syntax error. I’m a beginner with postgresql

  • 1

    Put the error message in the question. See if SET uniqueid = uniqueid + 1 works

  • I tried it but it will add up '1481126826 <-- 2363343 '

  • Have to add in decimal place

  • And with .1 in place of 1 ?

  • Doesn’t Work I tried here ..

  • Made a mistake or added wrong?

  • Syntax error

  • Then put 0.1 in place of .1

  • Vote today! Vote tomorrow! Vote forever! Vote consciously! Your vote is very important to our community, contribute to us, and help make Stack Overflow in Portuguese (Sopt) bigger and bigger. You can learn more at: Vote early, vote often

Show 6 more comments

3 answers

1

Just add to it yourself:

SET uniqueid = uniqueid  + 1

1

Try to use the nextval():

UPDATE callcenter.chamada_agente  
   SET uniqueid = nextval(uniqueid) --> Assim
 WHERE id_chamada_agente  = 32408 
   AND tipo_chamada = 'MANUAL'
   AND datahora_inicio BETWEEN '2016-11-01 00:00:00' AND '2016-12-15 23:59:59';

1

SUM() is an aggregation function, will not serve for what you want. For this, just add with the value you want to increase.

UPDATE callcenter.chamada_agente  
   SET uniqueid = uniqueid + 0.0000001 -- uniqueid é o que já tem o valor '1481126826.2363343', certo?
 WHERE id_chamada_agente  = 32408 
   AND tipo_chamada = 'MANUAL'
   AND datahora_inicio BETWEEN '2016-11-01 00:00:00' AND '2016-12-15 23:59:59';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.