Oracle order by

Asked

Viewed 405 times

2

Folks good afternoon when trying to execute the command below by ordering decreasing it displays the following Missing Expression error SELECT * FROM tab_estado WHERE nm_uf like'%MG%' and like'%BA%' order by desc ; Missing Expression

2 answers

2

The order by is used next to the column name used for sorting. Translating, it would be something like "sort by column". Just put the column name after the command order by that the consultation will work.

  • i put SELECT * FROM tab_status WHERE order by desc nm_uf like'%MG%' and like'%BA%'; but continues with the same error

  • 1

    To sort by nm_uf has to be: ... WHERE nm_uf like'%MG%' and nm_uf like'%BA%' order by nm_uf desc;. Also remember that order by is the last thing that appears in the query, it comes after the Where tests.

  • thanks for answering, man he did not run SELECT * FROM tab_estado WHERE nm_uf like'%MG%' or like'%BA%' order by nm_uf desc; deo the same error Missing expression

  • 1

    You are wrong in Where, it has to be: WHERE nm_uf like'%MG%' and nm_uf like'%BA%'. You cannot omit nm_uf from the 2 like.

  • thanks was even that rs error. I have another problem. When trying to run this command in oracle it presents the following error Missing right parenthesis. Meu comando oracle SELECT id_banco,vl_saldo FROM tab_conta WHERE (id_agencia=7 or id_agencia=12 or id_agencia=20) and (vl_saldo<2000,00) and id_banco=2;

  • Take this comma from 2000.00, I believe you should use the point(.), unless you have placed another locale in the bank, different from the standard.

Show 1 more comment

2

SELECT * 
FROM tab_estado 
WHERE (nm_uf like'%MG%' or nm_uf like'%BA%') 
order by nm_uf desc

Either the city is Minas or Bahia ... Order by asks for a column.

  • then Motta as would my command

  • Spun my sql @Felipe ?

  • thanks was even that rs error. I have another problem. When trying to run this command in oracle it presents the following error Missing right parenthesis. Meu comando oracle SELECT id_banco,vl_saldo FROM tab_conta WHERE (id_agencia=7 or id_agencia=12 or id_agencia=20) and (vl_saldo<2000,00) and id_banco=2;

  • It seems correct , add the ( and the ) must be equal .... :)

  • as well as add (and)

Browser other questions tagged

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