I am converting a few queries written for SQL Server 2005 into language and syntax that will work in SQL Server 2012. Some of the language in this query is deprecated and/or I'm not familiar with it. In the query below I know that COMPUTE has been replaced by ROLLUP.
The first thing I've come across which I am unfamiliar is why does the field c.employee_name have ,1 after it? Same question for d.client_name. I noticed I can change the 1 to other numbers, but I can't figure out the purpose of having it. I also noticed if I remove the ,1 the query does not work.
The second question is with the from clause three tables are references and aliased. This is probably basic to many people, but I have never seen this before and never referenced more than one table in a single from clause. I always have used joins. Is this normal syntax?
select
a.latest_period ,
b.offc,
convert(char(4), c.employee_name, 1),
d.client_code,
convert(Char(25), d.client_name, 1),
sum(tobill_amt)
from
CDT_disb a, hbm_matter b, hbm_persnl c, HBM_client d
where
a.matter_uno = b.matter_uno
and c.empl_uno = b.bill_empl_uno
and b.client_uno = d.client_uno
and a.latest_period between '200701' AND '200901'
and a.wip_status = 'W' and a.hardsoft = 'S' and a.tobill_amt <> 0
group by
a.latest_period, b.offc, c.employee_name, d.client_code, d.client_name
compute sum(sum(tobill_amt))
Here is a sample of the result set
latest_period offc (No Column Name) client_code (No Column Name) (No Column Name)
------------- ---- ---- ----------- ------------------------- -------------------------
200704 ATL Brav TAY003 Smith, James 14310.25
200704 MV Arms CLA002 Smith, Jane 2000