Sorry, didnt mention that the Top is a variable so cant use the SELECT TOP n
"Dan Guzman" <danguzman@nospam-earthlink.net> wrote in message news:<orMab.39754$NM1.39620@newsread2.news.atl.ear thlink.net>...[color=blue][color=green]
> > I think you forgot a TOP:
> >
> > SELECT
> > TOP 3 *,
> > (SELECT
> > COUNT(*)
> > FROM MyTable
> > WHERE MyColumn = 'SomeValue') AS NumberOfRows
> > FROM MyTable
> > WHERE MyColumn = 'SomeValue'
> > ORDER BY ID[/color]
>
> Yep. Thanks for adding it.
>
> --
> Hope this helps.
>
> Dan Guzman
> SQL Server MVP
>
> "Erland Sommarskog" <sommar@algonet.se> wrote in message
> news:Xns93FBF0D8C249Yazorman@127.0.0.1...[color=green]
> > Dan Guzman (danguzman@nospam-earthlink.net) writes:[color=darkred]
> > > Try something like:
> > >
> > > SELECT
> > > *,
> > > (SELECT
> > > COUNT(*)
> > > FROM MyTable
> > > WHERE MyColumn = 'SomeValue') AS NumberOfRows
> > > FROM MyTable
> > > WHERE MyColumn = 'SomeValue'
> > > ORDER BY ID[/color]
> >
> > I think you forgot a TOP:
> >
> > SELECT
> > TOP 3 *,
> > (SELECT
> > COUNT(*)
> > FROM MyTable
> > WHERE MyColumn = 'SomeValue') AS NumberOfRows
> > FROM MyTable
> > WHERE MyColumn = 'SomeValue'
> > ORDER BY ID
> >
> >
> >
> > --
> > Erland Sommarskog, SQL Server MVP,
sommar@algonet.se
> >
> > Books Online for SQL Server SP3 at
> >
http://www.microsoft.com/sql/techinf...2000/books.asp[/color][/color]