Re: Count unique values from overlapping values On Tue, 11 Mar 2008 11:20:06 +0100, Kim <kimslot@gmail.com> wrote:
> Sample data:
> colA,colB,sum
> 33996344,33996351,8
> 50331648,67276831,16945184
> 50331648,68257567,17925920
> 67276832,67276847,16
> 67276848,67277023,176
> 67277024,67277031,8
>
> Wanted output:
> 33996344,33996351,8
> 50331648,68257567,17925920
>
> Sum is done as follows (colB-colA+1).
> Any idea how to get this outcome ?
>
> This will give incorrect unique count, because it simply sums all up.
> SELECT sum(colB-colA+1) FROM tbl
If this is not what you want:
SELECT sum(colB-colA+1) FROM tbl
GROUP BY colA,colB
.... you'll have to explain the logic further, as I can't really see it.
What overlaps what, how, an how should that be handled?
--
Rik Wasmus |