Z
zizi2007 via AccessMonster.com
I need to create a sequence/order # field in a query so it puts the data in
order by 2 fields (company name and employee ID).
i.e.:
order company name employee ID total sales
1 acme 989785 32893.22
2 acme 9878753 455666.55
3 acme 564546 78.88
4 circuit city 892397 55687.47
5 jones cable 3893983 15036.78
6 jones cable 89211 2500.55
7 jones cable 3262222 305566.55
8 king soopers 56776 2
9 king soopers 113345456 456.55
(columns are not lined up--- but I hope you get the gist)
I tried this, but it didn’t work. – plus I want to set the order based on
the final results, not the subquery… right?
SELECT [company name], [employee id],
, sum([sales]) as [total sales]
, (select count(*)
FROM [Sales1] as c1
where c2.[employee ID] >= c1.[employee ID] ) as Seq_Order
FROM [Sales1] as c2
group by [company name], [employee id]
ORDER BY [company name], [employee id]
thank you for your help.
Z
order by 2 fields (company name and employee ID).
i.e.:
order company name employee ID total sales
1 acme 989785 32893.22
2 acme 9878753 455666.55
3 acme 564546 78.88
4 circuit city 892397 55687.47
5 jones cable 3893983 15036.78
6 jones cable 89211 2500.55
7 jones cable 3262222 305566.55
8 king soopers 56776 2
9 king soopers 113345456 456.55
(columns are not lined up--- but I hope you get the gist)
I tried this, but it didn’t work. – plus I want to set the order based on
the final results, not the subquery… right?
SELECT [company name], [employee id],
, sum([sales]) as [total sales]
, (select count(*)
FROM [Sales1] as c1
where c2.[employee ID] >= c1.[employee ID] ) as Seq_Order
FROM [Sales1] as c2
group by [company name], [employee id]
ORDER BY [company name], [employee id]
thank you for your help.
Z