I am trying to implement a simple search functionalitu over links.name column. I would like to match keywords against name values and wanted to get the names with more matchings on the top of result. …
Tag: postgresql
How to write a WHERE clause for NULL value in ARRAY type column?
I created a table which contains a column of string ARRAY type as: CREATE TABLE test ( id integer NOT NULL, list text[] COLLATE pg_catalog.”default”, CONSTRAINT test_pkey PRIMARY KEY (id) …
Need to select 2 most recent dates for 2 id’s
I need to return 2 most recent dates for each client id, i have 12345 and 112233 and for each of them i need to create a function which supposed to return to me this id | client_id | created …
Violation of uniqueness in primary key when using inheritance
I’m using inheritance in PostgreSQL but there is a big problem while using it. I have a Parent table and 2 Child Tables and I don’tknow how to insert a data in these tables. The uniqueness of Parent …
operator does not exist: timestamp without time zone ~~* unknown ruby code
I am try to query users in the database when I do a search. However i am getting a specific error which is ‘operator does not exist: timestamp without time zone ~~* unknown’ In my database, the …
Django annotate add interval to date
I am using postgres database with Django 2.2. I need to combine date and time field in model and add an interval of one day in it. I have done first part like this. Model.objects.annotate( end_dt=…
PostgreSQL – why is this statement causing a syntax error?
SELECT (SELECT COUNT(*) FROM table1) AS count1 WHERE date=’2019-06-12′, (SELECT COUNT(*) FROM table2) AS count2 WHERE date=’2019-06-12′ why is this statement causing a syntax error at …
Find the longest streak of perfect scores per player
I have a the following result from a SELECT query with ORDER BY player_id ASC, time ASC in PostgreSQL database: I’m trying to find each player’s longest streak where points = 100, with the tiebreaker being whichever streak began most recently. I also need to determine the time at which that player’s longest streak began. The expected result would be:
how to rewrite query to put data-modifying CTE at top level
I’m trying to write a query for Postgres to insert a row into one table which as a side-effect may insert a row into a second table (due to the first table having a foreign key constraint on the …
SQL Query doesn’t run as intended(between)
I have the following query(in postgresql), select distinct “bookings”.”memberId” from “shifts” inner join “bookings” on “bookings”.”shiftId” = “shifts”.”id” where “shifts”.”startTime” not …