Results 1 to 4 of 4

Thread: SELECT non NULL records, then sort them

  1. #1

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    SELECT non NULL records, then sort them

    Having trouble sorting records (using ADO with Excel VBA on Access DB file). The field I'm interested in can have numeric or NULL values. I only want the records with non-NULL values for field XX and then sort them. Using the following select statement, I get the records I want, but they aren't sorted. How to fix?

    Code:
    SELECT * FROM TestTable WHERE NOT ISNULL(XX) ORDER BY XX

  2. #2
    Addicted Member Smartacus's Avatar
    Join Date
    Oct 2009
    Location
    Deep South, USA
    Posts
    196

    Re: SELECT non NULL records, then sort them

    SELECT * FROM TestTable WHERE XX IS NOT NULL ORDER BY XX
    ***************************************************
    Smartacus comes packaged "As Is With No Warranty"

    ************* Useful Links ******************
    FAQs: Index / Database Development / .NET CodeBank /
    Before Posting Here...MSDN

    MZTools (I love this tool when using VB6 - Free) /

  3. #3

    Thread Starter
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: SELECT non NULL records, then sort them

    Quote Originally Posted by Smartacus View Post
    SELECT * FROM TestTable WHERE XX IS NOT NULL ORDER BY XX
    I tried that also. Same result. The sorting by XX doesn't make sense. Here is example of the result (showing XX only)

    Code:
    100.
    100.
    2.
    48.
    90.
    95.
    99.
    99.
    The thought just occurred to me that maybe the values are being interpreted as text. Need to check that...

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: SELECT non NULL records, then sort them

    Is XX a string field or a numeric field? I don't mean that the VALUE is numeric... but the actual DATA TYPE of the field itself?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width