Skip to content

Tag: postgresql

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 lo…

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-2…

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 contai…