select * from( select distinct customer_id, dense_rank()over( order by customer_id asc) rn_low, dense_rank()over( order by customer_id desc) rn_high from subscriptions as s ) t1 where rn_low <= 5 or rn_high <= 5 order by customer_id
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter