Skip to content
Advertisement

Tag: postgresql

Error: SQL Substring with the “ON” Part of the JOIN

I am using PostgreSQL and must join tables using substring. As I demonstrated below, xyz.MODEL and first three characters of “columnname” from abc Table should match. However, the query below does not work. It returns the error: Can anyone help me to correct this query? Thanks for your help already. Answer The table alias must precede the column name, not

Mikro-ORM: error: there is no parameter $1

Alright so I’ve been trying to search Mikro-ORM’s docs to find how to pass in native sql query params in but I haven’t been able to find anything. After playing with the code a bit this is what it looks like which I think is sort of right but I’m getting this error My code currently looks like this Just

Using outer query ID in a subquery

I have a table with a list of invoices with there statuses and reported date, let’s say each date we have new report could change the invoice status from PENDING to PAID. I want subquery the first date an invoice was paid for each invoice. The table looks like this: invoice_id report_date status A1 08-26-2021 PAID A2 08-26-2021 PENDING A3

pivot table with multiple value columns in postgres

I need a query which will help me to get data as described below I have a table as followed ID date STATUS TIME09_10 TIME10_11 TIME11_12 TIME12_13 1 2021-09-01 RUN 30 60 45 0 2 2021-09-01 WALK 15 0 o 30 3 2021-09-01 STOP 15 0 15 30 I want this data to be in below format. From the above

How to query this in raw SQL?

I have a table user with 2 columns, name and role. I want to group together for one role all the names which are associated with it. So suppose for the role “admin” is used by 3 different names. I want to start my query with this Answer listagg function should help. need to group the column containing “admin” then

Advertisement