Hi,
There is a table TABLE1 and the fields: ZIP, TERR, VAL:
ZIP TERR VAL
0001 01 10
0001 01 12
0001 01 14
0002 01 17
0002 01 21
0002 02 24
....
I need to roll them up by ZIP and TERR and present two sets of data: where ZIP has one only TERR and ZIP has more than one TERR.
I wrote this select that does half of the job: it rolls things up.
SELECT ZIP,
TERR,
SUM(VAL) AS TOTAL_VAL
FROM TABLE1
GROUP BY ZIP,
TERR
ORDER BY ZIP,
TERR;
I am not sure how to divorce results for ZIP 0001 and 0002 (they have different number of TERR - 1 and 2). I would prefer two separate queries for them.
Can anybody help?
Thanks!
vladk
There is a table TABLE1 and the fields: ZIP, TERR, VAL:
ZIP TERR VAL
0001 01 10
0001 01 12
0001 01 14
0002 01 17
0002 01 21
0002 02 24
....
I need to roll them up by ZIP and TERR and present two sets of data: where ZIP has one only TERR and ZIP has more than one TERR.
I wrote this select that does half of the job: it rolls things up.
SELECT ZIP,
TERR,
SUM(VAL) AS TOTAL_VAL
FROM TABLE1
GROUP BY ZIP,
TERR
ORDER BY ZIP,
TERR;
I am not sure how to divorce results for ZIP 0001 and 0002 (they have different number of TERR - 1 and 2). I would prefer two separate queries for them.
Can anybody help?
Thanks!
vladk