Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Explain SQL Server Query

Author  Topic 

jtrapat1
Starting Member

43 Posts

Posted - 2002-10-14 : 13:17:08
Could someone please explain the aggregate query below:
I have to convert this so that DB2 will understand it.
But,I want to understand it first under MS Sql Server.
--------------------------------------------------------
Insert into appropsdistinct
select distinct acode, right(pcode,3),catcode, fundcode, left(objectcode,1), sum(summaryvalue),0,0,0
from dob_bps
group by (acode + right(pcode,3) + catcode + fundcode + left(objectcode,1)), acode, right(pcode,3),catcode, fundcode, left(objectcode,1)
---------------------------------------
I don't understand the group by concatenation.


Thanks in advance
John

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-10-14 : 16:24:04
The concatenation in the group by shouldn't affect how you conceptualize the grouping - a collection by the engine of like values. The "value" may simply be a column value or it might be an expression involving one or more column values.

example:
a b
--- ---
0 2
0 3
1 3
2 5

select b-a, count(*)
from {rowset}
group by b-a

yields:
b-a count(*) (well, {no column name})
--- ---
2 2
3 2

Jonathan
{0}
Go to Top of Page
   

- Advertisement -