Bring data regardless of the order of the numbers are found

Asked

Viewed 57 times

-1

Good afternoon!

Can someone help me? I need to bring the data of a query (query) with the return as below, regardless of the order of the numbers are. I have a table of metrics, and this query is according to these metrics, and may be out of order. When I run the query, it always returns ordering. And I don’t want it this way, I need it to return as in the small example ( Need). And my query, will bring more than 100 columns,and these numbers may be random, but will follow as my select. The number 100 will always be the last.

Following example:

SELECT (codigo, Valor> BULK COLLECT INTO teste FROM tb_teste
(
select 1, 'Valor Produto' from dual
union all
select 2, 'Qtde Produto' from dual
union all
select 98, 'Descrição Produto' from dual
union all
select 101,'Qtde Vendas' from dual
union all
select 50, 'Qtde em Estoque' from dual
union all
select 97, 'Qtde Pedida' from dual
union all
select 100, 'Qtde a Entregar' from dual
)

Resultado:
+----+-----------------------+
| cd |     valor             |
+----+-----------------------+
| 1  | Valor Produto         |
| 2  | Qtde Produto          |
| 98 | Descrição Produto     |
|101 | Qtde Vendas           |
|100 | Qtde em Estoque       | 
+----+-----------------------+
  • This will come from a table or this mount via 'dual' !? I would create either an order column (not displayed) or a 1-Value type artifice ... 2-Qtde ...

  • Thanks for the return. Turns from a table, the Union all will exist... How do I make this column of order ( not displayed) or artificially type 1?

1 answer

0

1 your table would have : Cod , value , order

Seria

Select cod , valor
From tabela
Order by ordem

2 a 'gambiarra' :

SELECT (codigo, Valor> BULK COLLECT INTO teste FROM tb_teste
(
select 1, '1-Valor Produto' from dual
union all
select 2, '2-Qtde Produto' from dual
union all
select 98, '3-Descrição Produto' from dual
union all
select 101,'4-Qtde Vendas' from dual
union all
select 50, '5-Qtde em Estoque' from dual
union all
select 97, '6-Qtde Pedida' from dual
union all
select 100, '7-Qtde a Entregar' from dual
) order by 2
  • Wow, gratitude for the help. I’ll do here and post that worked. Good night!

  • Mptta, it was perfect! I did it like this:

Browser other questions tagged

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