DEV Community

Anjali Gurjar
Anjali Gurjar

Posted on

SQL

SELECT
REPEAT('* ', ROW_NUMBER() OVER () - 1) AS pattern
FROM
information_schema.tables
LIMIT 20;

SELECT Clause:

REPEAT('* ', ROW_NUMBER() OVER () - 1) AS pattern: This part of the query is responsible for generating the pattern. It uses the REPEAT function to repeat the '*' character followed by a space for a specific number of times. The number of repetitions is determined by ROW_NUMBER() OVER () - 1.
FROM Clause:

FROM information_schema.tables: The FROM clause is a standard SQL clause that specifies the source of the data. In this case, it uses the information_schema.tables table, but the specific table chosen is not crucial for the query's purpose. It's a common practice to use any table that has enough rows for the desired pattern.
ROW_NUMBER() OVER ():

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay