Showing posts with label nullselect. Show all posts
Showing posts with label nullselect. Show all posts

Wednesday, March 28, 2012

having example.

hi can anyone explain to me the diff between having and where?
set1
a b
1 2
1 NULL
1 3
2 NULL
2 1
1 NULL
select a,b from set1
where b =2
group by a,b
and
select a,b from set1
group by a,b
having b =2
both the above querries give me teh same result.
so i cant tell teh difference.WHERE applies before the grouping and aggregation, HAVING applies
afterwards the aggregation.
HTH, Jens Suessmeyer.|||You can use HAVING to apply a filter on grouped sets like
select a,b from set1
group by a,b
having COUNT(8) >2
Otherwise HAVING servers the same purpose as WHERE
Regards
Roji. P. Thomas
http://toponewithties.blogspot.com
"ichor" <ichor@.hotmail.com> wrote in message
news:uiO5W9PPGHA.3528@.TK2MSFTNGP10.phx.gbl...
> hi can anyone explain to me the diff between having and where?
> set1
> a b
> 1 2
> 1 NULL
> 1 3
> 2 NULL
> 2 1
> 1 NULL
>
> select a,b from set1
> where b =2
> group by a,b
> and
> select a,b from set1
> group by a,b
> having b =2
>
> both the above querries give me teh same result.
> so i cant tell teh difference.
>