Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

742
Views
TypeORM, createQueryBuilder with CAST and AS, any option?

I am using TypeORM with Nestjs, and after checking docs about TypeORM and github repo, can't find any example or answer of my problem.

I am having the following query:

SELECT * FROM (
    SELECT *, SUM(CAST("amountA" AS DECIMAL)) OVER (ORDER BY CAST("priceA" AS DECIMAL) ASC, id) AS quantity_amount
    FROM public."order"
    WHERE item_a_id= 1
    AND item_b_id = 4
    AND CAST("priceA" AS DECIMAL) <= CAST('92481' AS DECIMAL)
    ORDER BY "priceA" ASC
) AS c
WHERE c.quantity_amount <= CAST('100000' AS DECIMAL);

As you may see, it converts some varchar fields from string to decimanls because I am dealing with BigNumber and I am not using decimals in Entity.

And also I have this part, with AS c which is used later. So my question is:

Can I use createQueryBuilder of TypeORM and how exactly I should pass such string as: AND CAST("priceA" AS DECIMAL) <= CAST('92481' AS DECIMAL) and AS c and field quantity_amount from my subQuery?

Is there any other options? Because as for now, I am dealing with plain SQL and query method instead of createQueryBuilder.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!