Select on select data

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

Poston Thu, 11 Oct 2007 9:19 am

Good morning Guys, next I have a doubt, I'd like to see if you have to do the following: select SELECT NAME, ACCOUNT FROM (SELECT NAME, (SELECT count(*) FROM TABELA_RETORNADA_DO_CAMPO_NAME)) ORDER BY COUNT DESC Note: only respond if with Select same as with PL I managed to do OKAY.
meguelito
Location: Santa Catarina

Att.:
Alan Juliano Metzger
Programador Oracle
Inside System Informática
Msn/E-mail: alanjuliano@yahoo.com.br

Poston Thu, 11 Oct 2007 9:29 am

Yes, brother, here is an example with the syntax:
Code: Select all
SELECT d.deptno,
       d.valor,
                     d1.dname
FROM (SELECT d.deptno, COUNT(1) valor
        FROM dept d,
                             emp e
                        WHERE d.deptno = e.deptno
                        GROUP BY d.deptno) d,
                        dept  d1
WHERE d1.deptno = d.deptno
ORDER BY d1.dname;
Trevisolli
Location: Araraquara - SP

Abraço,

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

Poston Thu, 11 Oct 2007 10:44 am

Nice try cheezburger network, but it's not exactly what I want, the count has actually count the records from the table that even if I did a select count(*) from table understood.
meguelito
Location: Santa Catarina

Att.:
Alan Juliano Metzger
Programador Oracle
Inside System Informática
Msn/E-mail: alanjuliano@yahoo.com.br

Poston Thu, 11 Oct 2007 10:53 am

Brother, I think q não got it right.

You want an external count?
Also can you do.
qualquer thing, put here your code q I a force.
Trevisolli
Location: Araraquara - SP

Abraço,

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

Poston Thu, 11 Oct 2007 2:53 pm

WHAT IS THE NAME OF THE TABLE WHERE ARE STORED THE NAMES?
Renan Orati
Location: São José do Rio Preto - SP

Poston Sat, 13 Oct 2007 9:35 am

As I understand it:
Code: Select all
Tabela:

Nome    Conta
N01       C01
N01       C02
N01       C03
N02       C04
N02       C05
N03       C06
the expected result would be:
Code: Select all
Nome    Conta  Count(1)
N01       C01     6
N01       C02     6
N01       C03     6
N02       C04     6
N02       C05     6
N03       C06     6
If this is the case, try the following query:
Code: Select all
select nome, conta, count(1) over()
from   tabela
;
if not, try to put together a sample of your data and the expected result.
rogenaro
Location: Londrina - PR


  • See also
    Replies
    Views
    Last Post


      Return to SQL

      Who is online

      Users browsing this forum: No registered users and 3 guests