Jump to content

Select by DESC doesn't work?


Raven1313

Recommended Posts

 

I'm trying to select PVOL (a number) by desc to get the top 5 values of that column. But I don't  get the top 5 values of PVOL... I just get the highest which is LESS than 1,000,000 all the numbers above 1mil don't show up.

 

select PLAST,PREF,POPEN,PCLOSE,PBID,PVOL,PVALUE,PASK,TICKER  from  hist_sec where  DATE(PDATE) = DATE(NOW()) and PVOL != ''  order by PVOL DESC limit 0 , 5;

 

How do I select where I also include the numbers above 1 mil?

:shrug:

Link to comment
Share on other sites

Hello Barand,

 

Below is the result you request:

 

CREATE TABLE `hist_sec` (

  `PDATE` date NOT NULL,

  `STKNO` double NOT NULL,

  `ROWNO` double NOT NULL,

  `TICKER` varchar(25) NOT NULL,

  `NATIVE_TICKER` varchar(25) NOT NULL,

  `PREF` varchar(15) NOT NULL,

  `PLAST` varchar(15) NOT NULL,

  `POPEN` varchar(15) NOT NULL,

  `PHIGH` varchar(15) NOT NULL,

  `PLOW` varchar(15) NOT NULL,

  `PVOL` varchar(15) NOT NULL,

  `PVALUE` varchar(15) NOT NULL,

  `PTRADES` varchar(15) NOT NULL,

  `PCLOSE` varchar(15) NOT NULL,

  `PBID` varchar(15) NOT NULL,

  `PASK` varchar(15) NOT NULL,

  `CHANGE` varchar(15) NOT NULL,

  `VWAP` varchar(15) NOT NULL,

  `YHIGH` varchar(15) NOT NULL,

  `YLOW` varchar(15) NOT NULL

) ENGINE=MyISAM DEFAULT CHARSET=utf8

 

Link to comment
Share on other sites

If they don't have decimals then INT. If they have decimals then something like DECIMAL(12,2) assuming 2 dec places.

 

Also don't store the commas, format the numbers on output.

 

This is the result of sorting nubers DESC in a varchar field

+----------+
| title    |
+----------+
| 60000    |
| 50000    |
| 40000    |
| 15000000 |
| 12000000 |
| 1000000  |
+----------+

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.