Kharthik Raj
Kharthik Raj

Reputation: 29

Postgresql mathematical functions (factorial)

I have been learning postgresql, and for some reason when i do factorial operations, my terminal says: "syntax error at or near ';'".

Every other basic mathematical operations like add; sub; multiply; divide; modulo; power works, but not factorial operator.

I will link the screenshot of my terminal.

Please somebody help with this problem.screenshot

Upvotes: 1

Views: 2793

Answers (2)

Code on the Rocks
Code on the Rocks

Reputation: 17764

You can use the factorial() function to get the factorial you want. Ex:

SELECT factorial(5);  

Upvotes: 1

user330315
user330315

Reputation:

Postgres 14 removed the ! operator for factorial:

Remove factorial operators ! and !!, as well as function numeric_fac()
The factorial() function is still supported.

Upvotes: 10

Related Questions