How does this dot notation within SQL work?

557 Views Asked by At

I'm working with some SQL and trying to understand what is going on.

Within the select there are what seem like variables s.id s.status

with 
    last_transactions as (
        select 
            s.id as station_id, 
            s.status as status,
            case...........

What are these s. items and how do they work?

4

There are 4 best solutions below

0
Himanshu On

. notation is used to reference columns mainly of a table, view etc. schema objects or an aliased name of a schema object as above you have used s as alias name of some table so using s. the part after dot references to the column in that s or table aliased

0
GDes00 On

the s is the table name. s.id means the id column of the s table.

0
MarizaV. On

s. is a reference to the table name that derives from the From clause that probably follows in your query. The part after the . is the column name.

For example s.id means: Column 'id' from table 's'

0
Meetts On

S is table alias and through .dot we can access that table column.

Example..

Select S.id from Sample as S

It give you all id's of the sample table.