Home All Groups Group Topic Archive Search About

Can I write query like this

Author
20 Jan 2006 8:24 PM
Nick
hi, guys

Can I write query like this:
I need to get the amount of stores that have @PID inventory less than 2
select count(*) from
(
     select StoreID, sum(Inventory) as Inv from products where
productID = @PID group by storeID
) StoreInv where StoreInv.Inv <= 2

thanks.

Author
20 Jan 2006 8:34 PM
Mark Williams
select StoreID, sum(Inventory) as Inv from products
where productID = @PID
group by storeID
HAVING sum(Inventory) < 2
--


Show quote
"Nick" wrote:

> hi, guys
>
> Can I write query like this:
> I need to get the amount of stores that have @PID inventory less than 2
> select count(*) from
> (
>      select StoreID, sum(Inventory) as Inv from products where
> productID = @PID group by storeID
> ) StoreInv where StoreInv.Inv <= 2
>
> thanks.
>
>
Author
20 Jan 2006 8:53 PM
Jim Underwood
Select count(*) from
(
select StoreID, sum(Inventory) as Inv from products
where productID = @PID
group by storeID
HAVING sum(Inventory) < 2
)

Show quote
"Mark Williams" <MarkWilli***@discussions.microsoft.com> wrote in message
news:711CF005-0EEF-4A2A-895C-5DFBAA3DC031@microsoft.com...
> select StoreID, sum(Inventory) as Inv from products
> where productID = @PID
> group by storeID
> HAVING sum(Inventory) < 2
> --
>
>
> "Nick" wrote:
>
> > hi, guys
> >
> > Can I write query like this:
> > I need to get the amount of stores that have @PID inventory less than 2
> > select count(*) from
> > (
> >      select StoreID, sum(Inventory) as Inv from products where
> > productID = @PID group by storeID
> > ) StoreInv where StoreInv.Inv <= 2
> >
> > thanks.
> >
> >
Author
20 Jan 2006 9:17 PM
Mark Williams
Oops! Misread the original posting. Thanks for the correction.
--
If you posted to this forum through TechNet, and you found my answers
helpful, please mark them as answers.


Show quote
"Jim Underwood" wrote:

> Select count(*) from
> (
> select StoreID, sum(Inventory) as Inv from products
> where productID = @PID
> group by storeID
> HAVING sum(Inventory) < 2
> )
>
> "Mark Williams" <MarkWilli***@discussions.microsoft.com> wrote in message
> news:711CF005-0EEF-4A2A-895C-5DFBAA3DC031@microsoft.com...
> > select StoreID, sum(Inventory) as Inv from products
> > where productID = @PID
> > group by storeID
> > HAVING sum(Inventory) < 2
> > --
> >
> >
> > "Nick" wrote:
> >
> > > hi, guys
> > >
> > > Can I write query like this:
> > > I need to get the amount of stores that have @PID inventory less than 2
> > > select count(*) from
> > > (
> > >      select StoreID, sum(Inventory) as Inv from products where
> > > productID = @PID group by storeID
> > > ) StoreInv where StoreInv.Inv <= 2
> > >
> > > thanks.
> > >
> > >
>
>
>

AddThis Social Bookmark Button