group fasten same list twice
i'm minute query promulgate data. i have fall list fundamentally boolean, i need sums depends formed value it, following same thing value, so:
select
location
,count(*)
,sum(duration)
from my.table
where form = 'x'
plcae = @location
date(some_tstamp) = @date
group location
and following same another value form column. i join list twice, i still organisation i wholly public any table, i.e. count(a.*) instead count(*)...
would improved twin removed queries?
edit
thanks everybody, nonetheless that's i meant. i need outline where form = 'x' outline where form = 'y' separately...let me post improved example. i meant query this:
select
a.location
,count(a.*)
,sum(a.duration)
,count(b.*)
,sum(b.duration)
from my.table a, my.table b
where a.type = 'x'
a.location = @location
date(a.some_tstamp) = @date
b.location = @location
date(b.some_tstamp) = @date
b.type = 'y'
group a.location
what i need organisation by? also, db2 doesn't count(a.*), it's syntax error.
Comments
Post a Comment