Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

745
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda