Q:

String Manipulation in PostgreSQL

since am new database development my question may very basic.
How to get a output like below in PostgreSQL
 outputString
 ------------
 a
 aa
 aaa
 aaaa
 aaaaa
 aaaaaa
 aaaaaaa
 aaaaaaaa
 aaaaaaaaa
 aaaaaaaaaa

the total rows returned should be 10 

A:

you can achieve it using  WITH Queries (Common Table Expressions)
WITH RECURSIVE source (outputString) AS (
SELECT 'a'
UNION ALL
SELECT outputString || 'a'
FROM source
WHERE length(outputString) < 10
)
SELECT * FROM source;

Click here and read  to get more details about CTEs

