How do I filter the data downwards?

Asked

Viewed 71 times

3

I’m trying to filter the data from a table I have on SQL from the highest value to the lowest, but I’m not getting anywhere with Mysql.

Source code below

select max(id_nf), min(quantidade * valor_unit) AS VALOR_TOTAL from objects, 

Exercise below:

Search the total value of NF and sort the result of the highest value to the lowest. The columns present in the query result are: ID_NF, VALOR_TOTAL.

Remark: THE VALOR_TOTAL is obtained by the formula: ∑ QUANTIDADE * VALOR_UNIT.

  • what problem you’re encountering?

  • It is printing only one value, when I need several values to be printed from the highest to the highest.

1 answer

2


I think what the exercise calls for is a sum of the total amount that would be :

select id_nf,sum(quantidade * valor_unit) as valor_total 
from objects 
group by id_nf 
order by 2 desc
  • Managed to help me, thank you my consecrated!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.