Return on just one line

Tuning de Banco, Tuning de SQL, Ferramentas de tuning
Post Reply
scandolara
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Fri, 25 Jun 2004 9:18 am

PERSONALL Please

I have a SQL query that is returning me 2 lines, that is, 2 description.
I need this query to return to the invors of 2 rows, only 1.
Example:

Select name from product WHERE FAMILIAS PRODUCT = 'FAMILY'

Result is =
Product01
Product02

But I need to return
Product01 / Product02

How do I do this?

Thanks
diegolenhardt
Moderador
Moderador
Posts: 1177
Joined: Thu, 15 Oct 2009 10:28 am
Location: Recife

There are several topics in the forum, search for

result lines in spine, something like this,
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:

gustavosanmartin
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 11
Joined: Tue, 09 Jun 2009 10:46 am
Location: salvador - bahia

I believe that a consulted type below resolves:

Select all

select produto1 || produto2 
from tabela
lmendes.cps
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 13
Joined: Mon, 20 Jun 2011 2:14 pm
Location: Campinas - SP

Dude, I believe that with Select will be complicated, you can make a function with a cursor that mount the string the way you want. Example:

Select all

 
create or replace function conc_resultado(scondicao in varchar) return varchar2 is 
  Result varchar2(32000); 
  cursor c is 
   select familia from produtos where familia = scondicao; 
begin 
    for r in c loop 
       result := result ||'/'|| r.familia;  
    end loop;  
    return(Result); 
end conc_resultado; 
sysdigo
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 17
Joined: Sat, 12 Dec 2009 7:44 pm
Location: SP

I agree with miffs.

In summary you are wanting to transform lines in columns. Right?
The problem is that lines grow to the extent that new records are inserted. Therefore, it needs to be something dynamic as the fifths presented.
Search right here in Forum: How to transform lines into columns.

Hugs
ishii
Rank: Analista Júnior
Rank: Analista Júnior
Posts: 82
Joined: Tue, 28 Dec 2010 7:41 pm
Location: São Paulo - SP

Hello,

Take a look at this link and see if it helps you ...
http://www.dba-oracle.com/t_converting_rows_columns.htm

: -O
User avatar
fbifabio
Moderador
Moderador
Posts: 199
Joined: Tue, 22 Feb 2011 1:51 pm
Location: São Paulo - SP
Contact:

If you are using Oracle 11g, use the Analytical Listagg function. See the link http://www.oracle-base.com/articles/mis ... niques.php.
in my Tuning BD SQL training in Oracle (10G and 11G) I teach how to use these functions. See http://www.fabioprado.net/p/treinamentos.html
Att,

Fábio Prado www.fabioprado.net
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests