Repeat the column in Postgresql

In order to repeat the column in postgresql we use REPEAT() function. REPEAT() function of column in postgresql repeats the value of the column  n times. Let’s see how to

  • Repeat the column value in postgresql using REPEAT() function

Syntax of REPEAT():

repeat(,number_of_times)

We will be using Zipcodes table.

Repeat the column in Postgresql 1

 

Repeat the column in Postgresql:

In order to repeat the column value in postgresql we use repeat function along with the number of times to be repeated.

select *,REPEAT(state,3) as Repeat_n FROM zipcodes

Repeat function of state column repeats the column value 3 times so the resultant dataframe will be

Repeat the column in Postgresql 2

 

                                                                                                   

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.