I'm using the following query to print all title from stories table
select title from stories;
which show me all titles , The point here how to tweak it and do the following :
`order by longest title or even count longest title`
any tips
The PostgreSQL char_length function or character_length function is used to count the number of characters in a specified string. The CHARACTER_LENGTH() function is similar to CHAR_LENGTH() function. A string whose length is to be retrieved.
The PostgreSQL length() function is used to find the length of a string i.e. number of characters in the given string. Syntax: length(<string>) PostgreSQL Version: 9.3.
Get rows from past 24 hours in PostgreSQL In the above SQL query, we use PostgreSQL system function now() to get current datetime. Then we use INTERVAL clause to select those rows where order_date falls within past 24 hours of present datetime. You can also specify time interval in days, instead of hours.
If you to order by the length of the title (longest to shortest) you should use the following query
select title from stories order by length(title) desc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With