I have a table named tc_fuel that is receiving all the fuel related data from GPS vehicles, and I want to get the last “Tank Usage” to calculate MPG for a whole tank, but the readings when the tank is …
Tag: postgresql
Trouble inserting value into a TEXT column with Postgres
I am getting an error when I try to insert an alphanumeric value into a TEXT column in a Postgres DB. This is the table definition ]1 This is the query I am using to insert data into the table This is the error message I get ERROR: syntax error at or near “a0032000947363339343638” LINE 12: 55.2047…
Mersenne Primes processing
I took interest in Mersenne Primes https://www.mersenne.org/. Great Internet Mersenne Prime Search (GIMPS) is doing the research in this field. These are Prime Numbers but are very large and few. 49th Mersenne Prime is 22 million digits long. It is unbelievable that one number can be 22 million digits. I trie…
Retrieve start and last created date from a duplicated record
I have a table called mov_entrys and they have multiple historic records, in other words, duplicated records this is my main SQL statement SELECT me.mov_entry_id, me.mov_entry_ean13, me.plate, mv….
PostgreSQL missing FROM-CLAUSE entry
I have the following query: It tells me: ERROR: missing FROM-clause entry for table “sb.bookings” LINE 2: SELECT “shiftId”, “sb.bookings”.”state”, “visibleAt” FRO… I wrote it as “sb.bookings”.”state” because state is in …
Equivalent of string contains in google bigquery
I have a table like as shown below I would like to create two new binary columns indicating whether the subject had steroids and aspirin. I am looking to implement this in Postgresql and google bigquery I tried the below but it doesn’t work I expect my output to be like as shown below Answer Below is fo…
Ordering with PostgreSQL trigger when updating and inserting
I’m looking to sort the rows based on a variable. I’m pulling my hair out trying to wrap my head around this kind of trigger. I’ve only ever written triggers that gets some values from other tables. …
How to use LAST_VALUE in PostgreSQL?
I have a little table to try to understand how the LAST_VALUE function works in PostgreSQL. It looks like this: id | value —-+——– 0 | A 1 | B 2 | C 3 | D 4 | E 5 | [null] 6 | F …
Query JSONB column for any value where =?
I have a jsonb column which has the unfortunate case of being very unpredictable, in some cases its value may be an array with nested values: [“UserMailer”, “applicant_setup_3”, [“5cbffeb7-8d5e-4b52-…
How to convert PostGIS polygon coords into lat and lng?
From a json API, I am fetching data of an area displayed as a polygon. An endpoint example can be found here: https://admin.udinaturen.dk/api/v1/facilityread/?format=json&subcategory=40&limit=1 Here is a preview of the polygon displayed on the platform I am fetching the data from: http://udinaturen.dk…