Skip to content

Tag: postgresql

SQL – trimming values before bracket

I have a column of values where some values contain brackets with text which I would like to remove. This is an example of what I have and what I want: I have only come across approaches that use the number of characters or the position to trim the string, but these values have varying lengths. One way I was

Strange behavior from lag(), skipping over certain rows

I have a table we’ll call service, toy version is: The last five system fields are for database bookkeeping, and to enable soft (front end) deletion. There’s another table service_log which, together with service allows us to view a full revision history for each record in service. Fields of servi…

Update query with join and where clause

I’m currently confused with a (fairly easy) update statement that I’m trying to execute on a table. The two tables are as such: Customer table has the columns Loan table has the columns I would like to update the passworddisabled attribute to true if they are registered via a specific cash registe…

Where clause if true would not show at all

Have table where are two columns – client_id, content every client have +- 50 content rows. In WHERE i have this clause – where content NOT IN (‘2′,’3′,’4’) In result shows same clients but without rows where are ‘2’,’3′,’4′. …