Select complicated

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Wed, 02 May 2007 2:49 pm

Good afternoon guys, I'm a select sehuinte select way of tx_anexo from table1 t1, table2 t2 where t1. a = a and t1.cod = t2.561 this select returns two rows, me on the TX_ANEXO he returned a value X in the first line and in the second row a y. I wanted to set up this select in the form in which he would return the X and Y value on the same line next to each other. Can you help me???
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Wed, 02 May 2007 3:15 pm

Brother, I think it would be more or less this:
Code: Select all

SELECT t1.tx_anexo, (SELECT tx_anexo
                       FROM table2 t2
                       WHERE t2.a = t1.a) tx_anexo_2
  FROM table1 t1
WHERE t1.a = 1
   AND t1.cod = 1000

Who has any more ideas/solution, put there for people.
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Wed, 02 May 2007 3:23 pm

Today my select returns like this: cd_anexo cd_pesquisa tx_anexo--------------------------------------------------------633561 634561 bbbbbbbbbbbbbb aaaaaaaaaaaaaa I want that returns like this: tx_anexo1 tx_anexo2--------------------------------------------------------------------------aaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbb
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Wed, 02 May 2007 3:27 pm

Put a few lines of your table so we can have a look brother ...
Can this be case specific there, however, with the tables 1 and 2.

Vlw
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Wed, 02 May 2007 3:33 pm

My select original is this: select anex. tx_anexo the annex1, anex. tx_anexo the annex2 from db_pesquisa. tbl_anexo db_pesquisa. tbl_pesquisa, anex pesq, db_pesquisa. tbl_pessoa_empresa pessemp, db_pesquisa. tbl_pessoa pes where pesq.cd _ search = 561 and anex.cd _ search = pesq.cd _ search and pesq.cd search = search _ pessemp.cd _ and pessemp.cd _ person = pes.cd _ person who returns like this: Annex1 Annex2------------------------------------------------------------------------------A01_0023_Cópia of A01_0023_Cópia anexo_B_teste.doc anexo_D_A01_0023.doc of anexo_B_teste.doc anexo_D_A01_0023.doc note that has the same value for both columns, only that they are different on line and I want you to return only one row with each value stay in different columns.
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Wed, 02 May 2007 3:48 pm

Brother, you want to leave as exemplified below (the proposed)?
Just for me to place better ...

date:
Code: Select all
ANEXO1                                          ANEXO2
----------------------------------------------- -------------------------------
A01_0023_Cópia de anexo_B_teste.doc             A01_0023_Cópia de anexo_B_teste.doc
anexo_D_A01_0023.doc                            anexo_D_A01_0023.doc
: Proposed
Code: Select all
ANEXO1                                          ANEXO2
----------------------------------------------- -------------------------------
A01_0023_Cópia de anexo_B_teste.doc             anexo_D_A01_0023.doc
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Wed, 02 May 2007 3:54 pm

EXACTLY!!!!
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Wed, 02 May 2007 3:58 pm

beleza brother, I'll make some tests here and get back to you.
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Wed, 02 May 2007 4:02 pm

that's right, today is returned two rows and a single column and I want you to return a rows and two columns.
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Wed, 02 May 2007 5:23 pm

Got anything cheezburger network? ... I couldn't not, is difficult.
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Wed, 02 May 2007 5:45 pm

Brother, With PL/SQL can be or, only SQL?
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Wed, 02 May 2007 5:54 pm

Can be give the cheezburger network.
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Wed, 02 May 2007 6:14 pm

Here in the forum I was told something about CROSSTAB.
Look for it to find something!
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered

Poston Wed, 02 May 2007 10:55 pm

True Dr_Gori.
Thanks for the tip.

Cleber, try adapt as [url = ://glufke http . net/oracle/viewtopic php? t = . 844] this sample [/url] qualquer thing, says ai.
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Thu, 03 May 2007 2:50 pm

my field is varchar2... can't add, I can't use the group function ... There's no other way out?
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza

Poston Thu, 03 May 2007 4:02 pm

It Worked!!!!

I got this way:
Code: Select all
select pesq.cd_pesquisa,
         max(anex.tx_anexo)  Anexo_1,
         min(anex.tx_anexo)  Anexo_2     
from db_pesquisa.tbl_anexo anex,
        db_pesquisa.tbl_pesquisa pesq,
       db_pesquisa.tbl_pessoa_empresa pessemp,
       db_pesquisa.tbl_pessoa pes
where pesq.cd_pesquisa = 561
  and  anex.cd_pesquisa = pesq.cd_pesquisa
  and  pesq.cd_pesquisa = pessemp.cd_pesquisa
  and  pessemp.cd_pessoa = pes.cd_pessoa     
group by pesq.cd_pesquisa
order by 1
cleberzumba
Location: Brasília-DF

Cleber Zumba de Souza



Return to SQL

Who is online

Users browsing this forum: No registered users and 4 guests