Skip to content

Tag: postgresql

Full text search failure on PostgreSQL

I have a PostgreSQL used to index text content. The SearchVector column is created successfully using the following code The content looks like the following: But if I try to run a query to get plurals or singular of manual (in Italian: manuale is one, manuali are 2 or more) it fails: return nothing return no…

Generate random pairs SQL

Suppose we have these two tables. TABLE1: TABLE_2: I want to pair all rows of TABLE_1 with some random columns from TABLE_2 where each pair is gonna have a random amount of distinct rows from TABLE_2 (range 1,2,3) An output could be: Answer did the thing for me.

Filtering in count function – Postgresql

I have the following query which gives me the amount of referrals users have. However, I would like to only count the referral if the referred user has activated the premium plan. How could this be achieved? Dbfiddle here. I am using PostgreSQL version 14. Answer You can try to use FILTER clause or condition …