Jump to content
Developer17

Query group by

Recommended Posts

Developer17

Boas tardes, será que alguém me consegue dar uma ajuda numa query?

Não sei se é possível fazê-lo mas tenho o seguinte:

Tabela A:                         Tabela B:                                                    Tabela C:

Campo: Área                   Campo: No              Campo: Nome             Campo: Data

Variáveis:                         Variáveis:                Variáveis:                    Variáveis:

Comercial                              1                        Ana                             05-07-2007

Comercial                              2                       Carlos                          31-12-2008

Comercial                              3                       António                        02-09-2001

Técnica                                 1                       Raquel                         31-12-2008

Técnica                                 2                       Carina                          05-01-2007

Técnica                                 3                       João                             04-03-2002

A minha query é a seguinte:

select a.area, b.no, b.nome, c.data
from a
inner join b on b.no=a.no
inner join c on c.nome=b.nome
group by a.area, b.no, b.nome, c.data

Isto vai-me dar uma listagem tal como está aqui.

O que pretendo é agrupar por área. Tipo isto:

Comercial

1          Ana               05-07-2007

2         Carlos            31-12-2008

3         António          02-09-2001

Técnica

1        Raquel            31-12-2008

2        Carina            05-01-2007

3        João               04-03-2002

Isto é possível?

 

Share this post


Link to post
Share on other sites
M6

Faz "order by area, no, nome, data" depois do group by.


10 REM Generation 48K!
20 INPUT "URL:", A$
30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50
40 PRINT "404 Not Found"
50 PRINT "./M6 @ Portugal a Programar."

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.