1

I am looking for a way how to dynamically define and assign a value/-s for a variable in PostgreSQL within a query.

A very primitive MySQL example which should be translated into PostgreSQL would be as follows:

SELECT
  myVar1 := 15,
  myVar2 := 10,
  @myVar1 + @myVar3 AS myVar1_plus_myVar2

Note that everything is declared within SELECT section.

LordRudolf
  • 63
  • 8
  • https://dbfiddle.uk/?rdbms=postgres_13&fiddle=fd3d738daf0523e1b59fc04ac5a97300 –  Mar 10 '21 at 13:46

0 Answers0