Reputation: 11
I have not used SQL in a while but need to create some reports. I'm trying to learn again but not sure of how to find the info. In the script below what are the p1 & p2 called? Are these just columns in the payroll table?
select distinct p1.* from PAYROLL p1, PAYROLL p2
where
p1.EFFORTLINEITEMID = p2.EFFORTLINEITEMID
and p1.PAYROLLAMOUNT = p2.PAYROLLAMOUNT
and convert(varchar,p1.PAYROLLSTARTDATE, 101)=convert(varchar,p2.PAYROLLSTARTDATE, 101)
and p1.PAYROLLID <> p2.PAYROLLID
and p1.INSTITUTIONID ='######'
and p1.PERIODSTARTDATE ='9/1/12'
order by PERIODSTARTDATE desc,CERTIFIERID, PAYROLLAMOUNT
Upvotes: 1
Views: 45
Reputation: 172588
In the script below what are the p1 & p2 called?
These are the alias names of your tables. You have created two alias names p1
and p2
for your table PAYROLL
.
For more information or details check ALIAS
On a side note:-
As marc_s correctly pointed you should try to avoid the habit of joining tables using comma. Instead try using JOINS. Check Bad habits to kick : using old-style JOINs for reasons.
Upvotes: 3