Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7996799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:47:45+00:00 2026-06-04T14:47:45+00:00

ORDER BY is not working properly for numbers,but it’s working well if I give

  • 0

ORDER BY is not working properly for numbers,but it’s working well if I give for columns containing alphanumeric or only characters. The code which I had given is,

dbResult = dbStatement.executeQuery("SELECT Bid_Number,Vendor_Name,Vendor_Address,Amount,Tax_Percentage,Amount_Aftertax,Expected_Deliverydate,Vendor_Code FROM purchase_bid    where PE_Number='"+PENumber+"' ORDER BY Amount_Aftertax ASC"); 

if in my table I’ve Amount_Aftertax column values as,

840.0
780.0
3180.0
3810.0

by giving this code,i’m getting result according to this order

3180.0
3810.0
780.0
840.0

Hoping a reply please…
Thanks in advance..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:47:46+00:00Added an answer on June 4, 2026 at 2:47 pm

    It sounds like your column type is still a text column, even though it contains numbers – so they’re being sorted lexicographically. If you want them to be treated as numbers, you should make the column type a number too.

    This doesn’t just affect ordering, of course – all your code is likely to improve when you use appropriate types for your column. Just because you can stick pretty much any data in a string doesn’t mean it’s a good idea. Choose the data type which most closely matches the real data involved.

    Additionally, you shouldn’t specify the PENumber value like that – you should use a prepared statement, with a placeholder parameter in the SQL, which you provide the value for separately. Constructing SQL dynamically can lead to SQL Injection vulnerabilities, as well as unnecessary conversions and a poor separation of code from data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi Order By not working on MySql the code is as follows, select *
Order by descending is not working on LINQ to Entity In the following Query
Why is this thing not working? [Database(Name=Relationships_Test)] [Table(Name = Order)] public class Order {
I want to change order in plist file not programmatically but from xcode. Is
I'm currently experiencing a problem with 'hot code replace' not working on Eclipse Galileo
I am using JavaScript to specify the target link. It is not working properly.
Cake PHP complex find 'OR' opertor is not working properly with null... $conditions =
I'm working with an older version of Rails and ActiveRecord that does not have
Problem: I want to list n number of games from each genre (order not
I am using Autofac to handle dependency injection in my application. In order not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.