Skip to content
Advertisement

How to concatenate a query with knextjs

Im trying to archive this SQL to Knext but i dont know how to do it

THIS IS THE ORIGINAL QUERY and is fully functional in postgresql using the console

JavaScript

THIS IS HOW IM TRYING TO ARCHIVE with knextjs

JavaScript

Expected result:

JavaScript

Get:

JavaScript

Advertisement

Answer

Ok. this is the final and correct answer using the same subquery; thanks to Mikael for the amazing help.

Original SQL:

JavaScript

Knex style query:

Subquery:

JavaScript

Main query:

JavaScript

Expected and Given result:

JavaScript

And like Mikael says, there’s a little difference between the original query and this one, but for the database result is the same.

Advertisement