Hello, looking for some sql help again. Let’s say I have the following data returned from a query: SELECT DISTINCT(future_name) FROM table_a
FUT-23, FUT-24, FUT-25, … , FUT-32
The final two digits represent years. The smallest year is always one year ahead of the current year and the last year is always 10 years ahead of the current year.
I am looking for a query that would return these values in a following way:
row1: FUT-23, FUT-24, FUT-25, FUT-26, FUT-27
row2: FUT-24, FUT-25, FUT- 26, FUT-27, FUT-28
.
.
.
row7: FUT-29, FUT-30, FUT-31, FUT-33
row8: FUT-30, FUT-31, FUT-32
row9: FUT-31, FUT-32
I would be using these as a filter in a Grafana dashboard so these could be formatted as a string str(‘FUT-23’, ‘FUT-24’, … , ‘FUT-27’)
Thank you very much.
EDIT: I may have overcomplicated things since I can just split_part the int part of the string and use < and > operators. As I am using Grafana, I can just add these as query variables.
submitted by /u/theManag3R
[link] [comments]
Go to Source of this post
Author Of this post: /u/theManag3R
Title Of post: “Rolling” window of years
Author Link: {authorlink}
More Stories
Create Table Command In Postgresql
Mutex 22 in Postgres Version 14
Which tool/library well adopted to use Postgres as a message broker?