Difference between select a. or b [closed]

4

What is the difference of doing the search by select a. or b.?

Example:

select --a.num_duplicata,a.data_prorrogacao,a.seq_duplicatas,
        a.cli_dup_cgc_cli9 as cgc9,a.cli_dup_cgc_cli4 as cgc4,a.cli_dup_cgc_cli2 as cgc2,b.nome_cliente as cliente,
        sum(a.saldo_duplicata) as saldo_vencer
        --a.saldo_duplicata
from fatu_070 a, pedi_010 b
where a.codigo_empresa > 0
      and a.cli_dup_cgc_cli9 = b.cgc_9
      and a.cli_dup_cgc_cli4 = b.cgc_4
      and a.cli_dup_cgc_cli2 = b.cgc_2
      and (b.grupo_economico = &gru or b.grupo_economico = &gru2)
      and a.data_prorrogacao >= current_date - 1
      --and b.nome_cliente like 'naya je%'
      --and a.num_duplicata = 77486
group by a.cli_dup_cgc_cli9, a.cli_dup_cgc_cli4, a.cli_dup_cgc_cli2, b.nome_cliente
order by a.cli_dup_cgc_cli9, a.cli_dup_cgc_cli4, a.cli_dup_cgc_cli2, b.nome_cliente
    
asked by anonymous 18.10.2017 / 17:08

1 answer

3

Suppose the example we want to list the name of the Official and its respective Position:

SELECT f.nome, d.cargo
FROM Funcionario f 
INNER JOIN Departamento d
ON F.IdCargo = D.IdCargo

Note that I used the 'f' to refer to columns in the Employee table, and the 'd' to reference the columns from the Department table. That is, I did nothing more than APPROPRIATE the tables so that the SQL code would not be extensive. This code below would get the same result without the use of nicknames, which we call 'alias' . It would look like this

SELECT Funcionario.nome, Departamento.cargo
FROM Funcionario 
INNER JOIN Departamento
ON Funcionario.IdCargo = Departamento.IdCargo

I hope I have helped.

    
18.10.2017 / 17:58