Return in only one row

Tuning de Banco, Tuning de SQL, Ferramentas de tuning

Poston Tue, 05 Apr 2011 10:34 am

Facebook friends, blame me please, I have a SQL query that this returning me 2 lines, i.e. 2 Description.
I need this query returns instead of 2 lines, only 1.
Example: select ProductName from product where familiaproduto = ' FAMILY ' result is = Produto01 Produto02 But I need return Produto01/Produto02 how do I do it?

Thank you

Poston Tue, 05 Apr 2011 10:40 am

There are several threads on the Forum, search by result rows in column or something,
Location: Recife

Poston Tue, 05 Apr 2011 11:12 am

It searches for CROSSTAB viewtopic.php?t=1651
Location: Seattle, WA, USA

Poston Fri, 06 May 2011 8:57 pm

I believe a queried type below to solve: select product description1 || Product2 from table.
Location: salvador - bahia

Poston Thu, 07 Jul 2011 9:57 am

Dude, I believe with select will be complicated, you can make a function with a cursor that fit the string the way you want to. Example:
Code: 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;
    for r in c loop
       result := result ||'/'|| r.familia;
    end loop;
end conc_resultado;
Location: Campinas - SP

Poston Fri, 15 Jul 2011 12:10 pm

I agree with Imendes.

In short you are wanting to transform rows into columns. Right?
The problem is that the lines grow to the extent that new records are inserted. Therefore, it needs to be something dynamic as the Imendes presented.
Search right here in the forum: how to turn rows into columns.

Location: SP

Poston Fri, 15 Jul 2011 3:27 pm

Hello, check out this link and see if it helps.

Location: São Paulo - SP

Poston Wed, 10 Aug 2011 8:27 pm

If you are using Oracle 11 g, use the analytic LISTAGG function. Heres the link ... niques.php.

In my BD SQL tuning training at Oracle (10 g and 11 g) I teach how to use these functions. View Att, Fabio Prado
Location: São Paulo - SP

  • See also
    Last Post

Return to DBA Tuning

Who is online

Users browsing this forum: No registered users and 1 guest