Skip to content

Tag: postgresql

how to do sum with multiple joins in PostgreSQL?

I know that my question would be duplicated but I really don’t know how to created sql which return results of sum with multiple join. Tables I have result_summary summary_assembly employees info_product machine query result expected output(when sum by num_lot) All of them were modified from original on…

how to use wildcard for a column jsonb type

I have a table (named profile) in my Postgres database, which has 3 columns: ID, Day, Ftfm_profile of type jsonb, I tried to extract the row where the profile name (ftfm_profile->’name’) begins with ‘LFBB’ ( sql: LFBB%) using the wildcard as following: the expected result: I can&#82…

How to list last 7 days records in postgresql?

I want to display current date and previous 7 days. the query doesnt work for me. Answer I doubt you have future entry dates. So don’t use between. Instead: Note: If you want to count the current date as a day, then you want interval ‘6 days’.

Sum two column values on the basis of two name column

I am new to Postgres database. I am given 4 columns homeTeamName, homeTeamGoals, awayTeamGoals, awayTeamName. I want to find out the total goal(homeTeamGoals + awayTeamGoals) scored by each team. the database is as follows I think my solution is wrong. So looking for a better way Answer You can separate the t…

Update partial jsonb field in Postgres 13

can anyone help please optimize SQL request Postgres 13 (jsonb). Need to update the “percent” values inside the Jsonb field with the specified ID This example is working, but it works for a very long time on a large database. https://dbfiddle.uk/?rdbms=postgres_13&fiddle=a521fee551f2cdf8b189ef…