Skip to content
Advertisement

How to use PostgreSQL column value with some calculations as second column value

I am inserting a huge data set into the SQL table and I want to achieve something like this.

The problem is I don’t want to call generate_series function for b and c. I want to take the value of a and perform mod on it for b and c like below or even efficient way but I am unable to understand this how can I do it efficiently as I will be generating and saving 1 Million records.

Advertisement

Answer

Use a from clause:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement