Skip to content
Advertisement

Tag: postgresql

Correct use of a LATERAL FROM

I am trying to use PostGIS to undertake a number of steps within an SQL statement to basically convert a raster to points, buffer, dissolve and then determine the overall boundary i.e. concave hull based on an attribute. The following is where I am at but get an error suggesting the use of a LATERAL FROM but I do not

Two rows in two columns

I have table: Owner Book Date John Vile Bodies by Evelyn Waugh 2009-05-20 Tom Vile Bodies by Evelyn Waugh 2009-05-22 Jim Moab is my Washpot by Stephen Fry 2009-05-26 Kate Moab is my Washpot by Stephen Fry 2009-06-02 How can I get table: Owner Book Pick_Date Gave_Back_Book_Date John Vile Bodies by Evelyn Waugh 2009-05-20 2009-05-22 Tom Vile Bodies by Evelyn

Running query against all schemas in Postgres

Context We do schema-based multi-tenancy in our Postgres DB. Each and every schema is associated to a different tenant and will have the exact same structure except for one schema named public. To obtain the list of all the relevant schemas, we can use: Problem We need to periodically clean up a specific table for all the tenants: (The actual

Dynamic/Customized Week Number

Let us say there is a table which stores data for student’s attendance for classes. The student only need to attend each class once weekly. Hinging on the days_diff column, we decide which weeks the student should get credited for. As usual, each week has 7 days and the end of the week (in days) is divisible by 7. There

Querying JSON in POSTGRESQL returns NONE everytime

jsonb column text_results contains values in the following form : {‘Name’ : ‘john doe’ , ‘id’ : ‘123’} On querying Select text_results->>’Name’ as Name from user_master or Select json_extract_path_text(text_results::json,’Name’) as name from user_master it always return None without any error even though values are present. Need help with rectifying the error or any other way of extracting values from json

Foreign key constraint : alternative for one to one relation with split tables

For tables like this: Book AudioBook PaperBook Is there other way to ensure that PaperBook and AudioBook will not have same book_id without type column on them (remove FK constraint book_id + type references Book and type on childs? Example without fk constraint where AudioBook and PaperBook can have book_id=1 at the same time: Book AudioBook PaperBook Answer approach one:

Advertisement