select * from SaleVolumn order by Sales DESC
for example i have 3 value
132
222
1122
now it order by
222
132
1122
but what i want is the biggest come first.
what should i do?
****************************************
*
* This message was posted via http://www.droptable.com
*
* Report spam or abuse by clicking the following URL:
* [url]http://www.droptable.com/Uwe/Abuse.aspx?aid=b1aa3babb0da40f38a18f948b92aa1e1[/u
rl]
****************************************
*Is the datatype of the Sales coulmn char or varchar?
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"Gabe Wong via droptable.com" <forum@.droptable.com> wrote in message
news:b1aa3babb0da40f38a18f948b92aa1e1@.SQ
droptable.com...
> select * from SaleVolumn order by Sales DESC
>
> for example i have 3 value
> 132
> 222
> 1122
> now it order by
> 222
> 132
> 1122
> but what i want is the biggest come first.
> what should i do?
> ****************************************
*
> * This message was posted via http://www.droptable.com
> *
> * Report spam or abuse by clicking the following URL:
> *
http://www.droptable.com/Uwe/Abuse...a18f948b92aa1e1">
> ****************************************
*|||Looks like your Sales column could be a VARCHAR/CHAR rather than a numeric
type. If so, it will make sense to change this in your table structure but
for now you can do:
SELECT *
FROM SaleVolume
ORDER BY CAST(sales AS INTEGER) DESC
David Portas
SQL Server MVP
--sql
Showing posts with label descfor. Show all posts
Showing posts with label descfor. Show all posts
Monday, March 26, 2012
Order By in Biggest Value
Order By in Biggest Value
select * from SaleVolumn order by Sales DESC
for example i have 3 value
132
222
1122
now it order by
222
132
1122
but what i want is the biggest come first.
what should i do?
*****************************************
* This message was posted via http://www.sqlmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.sqlmonster.com/Uwe/Abuse...18f948b92aa1e1
*****************************************
Is the datatype of the Sales coulmn char or varchar?
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"Gabe Wong via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:b1aa3babb0da40f38a18f948b92aa1e1@.SQLMonster.c om...
> select * from SaleVolumn order by Sales DESC
>
> for example i have 3 value
> 132
> 222
> 1122
> now it order by
> 222
> 132
> 1122
> but what i want is the biggest come first.
> what should i do?
> *****************************************
> * This message was posted via http://www.sqlmonster.com
> *
> * Report spam or abuse by clicking the following URL:
> *
http://www.sqlmonster.com/Uwe/Abuse...18f948b92aa1e1
> *****************************************
|||Looks like your Sales column could be a VARCHAR/CHAR rather than a numeric
type. If so, it will make sense to change this in your table structure but
for now you can do:
SELECT *
FROM SaleVolume
ORDER BY CAST(sales AS INTEGER) DESC
David Portas
SQL Server MVP
for example i have 3 value
132
222
1122
now it order by
222
132
1122
but what i want is the biggest come first.
what should i do?
*****************************************
* This message was posted via http://www.sqlmonster.com
*
* Report spam or abuse by clicking the following URL:
* http://www.sqlmonster.com/Uwe/Abuse...18f948b92aa1e1
*****************************************
Is the datatype of the Sales coulmn char or varchar?
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com
"Gabe Wong via SQLMonster.com" <forum@.SQLMonster.com> wrote in message
news:b1aa3babb0da40f38a18f948b92aa1e1@.SQLMonster.c om...
> select * from SaleVolumn order by Sales DESC
>
> for example i have 3 value
> 132
> 222
> 1122
> now it order by
> 222
> 132
> 1122
> but what i want is the biggest come first.
> what should i do?
> *****************************************
> * This message was posted via http://www.sqlmonster.com
> *
> * Report spam or abuse by clicking the following URL:
> *
http://www.sqlmonster.com/Uwe/Abuse...18f948b92aa1e1
> *****************************************
|||Looks like your Sales column could be a VARCHAR/CHAR rather than a numeric
type. If so, it will make sense to change this in your table structure but
for now you can do:
SELECT *
FROM SaleVolume
ORDER BY CAST(sales AS INTEGER) DESC
David Portas
SQL Server MVP
Subscribe to:
Posts (Atom)