Thursday, March 8, 2012

Can I write query like this

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.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.
>|||Select count(*) from
(
select StoreID, sum(Inventory) as Inv from products
where productID = @.PID
group by storeID
HAVING sum(Inventory) < 2
)
"Mark Williams" <MarkWilliams@.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:
>|||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.
"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" <MarkWilliams@.discussions.microsoft.com> wrote in message
> news:711CF005-0EEF-4A2A-895C-5DFBAA3DC031@.microsoft.com...
>
>

No comments:

Post a Comment