Sunday, February 12, 2012

Bottom 10?

I know the select distinct TOP 10 returns top ten highest price items but
what about top 10 lowest priced items?
Thanks
S.This is a multi-part message in MIME format.
--=_NextPart_000_04E8_01C3CEEC.B41FEA20
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit
It's all in the ORDER BY:
select top 10
*
from
MyTable
order by
Price -- 10 cheapest
select top 10
*
from
MyTable
order by
Price DESC -- 10 most expensive
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"SMAN" <ksanti@.nycap.rr.com> wrote in message
news:ODQ$ZYxzDHA.2156@.TK2MSFTNGP09.phx.gbl...
I know the select distinct TOP 10 returns top ten highest price items but
what about top 10 lowest priced items?
Thanks
S.
--=_NextPart_000_04E8_01C3CEEC.B41FEA20
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

It's all in the ORDER BY:
select top 10
=*
from
=MyTable
order by
=Price -- 10 cheapest
select top 10
=*
from
=MyTable
order by
Price DESC -- 10 most =expensive
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"SMAN" wrote in message news:ODQ$ZYxzDHA.2156=@.TK2MSFTNGP09.phx.gbl...I know the select distinct TOP 10 returns top ten highest price items =butwhat about top 10 lowest priced items?ThanksS.

--=_NextPart_000_04E8_01C3CEEC.B41FEA20--|||SELECT TOP 10 * FROM <your table> ORDER BY Price
"SMAN" <ksanti@.nycap.rr.com> wrote in message
news:ODQ$ZYxzDHA.2156@.TK2MSFTNGP09.phx.gbl...
> I know the select distinct TOP 10 returns top ten highest price items but
> what about top 10 lowest priced items?
> Thanks
> S.
>|||ahh...makes cents to me now...thank you so much!!!!
"J Young" <thorium48@.hotmail.com> wrote in message
news:OohzYexzDHA.4060@.TK2MSFTNGP11.phx.gbl...
> SELECT TOP 10 * FROM <your table> ORDER BY Price
> "SMAN" <ksanti@.nycap.rr.com> wrote in message
> news:ODQ$ZYxzDHA.2156@.TK2MSFTNGP09.phx.gbl...
> > I know the select distinct TOP 10 returns top ten highest price items
but
> > what about top 10 lowest priced items?
> >
> > Thanks
> >
> > S.
> >
> >
>|||This is a multi-part message in MIME format.
--=_NextPart_000_053D_01C3CEEF.AEBA81F0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit
But will it make dollars to you later ... ;-)
--
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"SMAN" <ksanti@.nycap.rr.com> wrote in message
news:OkpBWjxzDHA.1736@.TK2MSFTNGP09.phx.gbl...
ahh...makes cents to me now...thank you so much!!!!
"J Young" <thorium48@.hotmail.com> wrote in message
news:OohzYexzDHA.4060@.TK2MSFTNGP11.phx.gbl...
> SELECT TOP 10 * FROM <your table> ORDER BY Price
> "SMAN" <ksanti@.nycap.rr.com> wrote in message
> news:ODQ$ZYxzDHA.2156@.TK2MSFTNGP09.phx.gbl...
> > I know the select distinct TOP 10 returns top ten highest price items
but
> > what about top 10 lowest priced items?
> >
> > Thanks
> >
> > S.
> >
> >
>
--=_NextPart_000_053D_01C3CEEF.AEBA81F0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

But will it make dollars to you later =... ;-)
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"SMAN" wrote in message news:OkpBWjxzDHA.1736=@.TK2MSFTNGP09.phx.gbl...ahh...makes cents to me now...thank you so much!!!!"J Young" =wrote in messagenews:OohzYexzDHA.4060=@.TK2MSFTNGP11.phx.gbl...> SELECT TOP 10 * FROM ORDER BY =Price>> "SMAN" wrote in message> news:ODQ$ZYxzDHA.2156=@.TK2MSFTNGP09.phx.gbl...> > I know the select distinct TOP 10 returns top ten highest price itemsbut> > what about top 10 lowest priced =items?> >> > Thanks> >> > S.> =>> >>>

--=_NextPart_000_053D_01C3CEEF.AEBA81F0--|||You had better throw in 'WITH TIES'.
Else, you'll get screwed when there are a few products with the same price.
And that goes for your 'TOP 10 highest' query too.
James Hokes
"J Young" <thorium48@.hotmail.com> wrote in message
news:OohzYexzDHA.4060@.TK2MSFTNGP11.phx.gbl...
> SELECT TOP 10 * FROM <your table> ORDER BY Price
> "SMAN" <ksanti@.nycap.rr.com> wrote in message
> news:ODQ$ZYxzDHA.2156@.TK2MSFTNGP09.phx.gbl...
> > I know the select distinct TOP 10 returns top ten highest price items
but
> > what about top 10 lowest priced items?
> >
> > Thanks
> >
> > S.
> >
> >
>

No comments:

Post a Comment