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 1109503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:14:45+00:00 2026-05-17T02:14:45+00:00

select p.Id, sum(inc.Quantity) from Products p join Incomes inc group by p.Id order by

  • 0
select p.Id, sum(inc.Quantity) 
from Products p join Incomes inc
group by p.Id 
order by sum(inc.Quantity) >0

This query gives NHibernate.Hql.Ast.ANTLR.QuerySyntaxException on ORDER BY clause. I wonder is it possible to overcome this error and perform sorting by some expression?

UPDATE
I need to sort products list by name, price etc. BUT products with quantity == 0 must go to the bottom of the list (no matter what name, price it has). Also I need to perform paging of that list.

  • 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-05-17T02:14:45+00:00Added an answer on May 17, 2026 at 2:14 am

    You need a syntax that is supported by SQL too. This works:

    select p.Id, sum(inc.Quantity) 
    from Products p join p.Incomes inc
    group by p.Id 
    order by case when sum(inc.Quantity) > 0 then 0 else 1 end
    

    Nitpicking: why do your entities have plural names?

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

Sidebar

Related Questions

$query = SELECT sum(o.feeship) feeship_total, (SELECT SUM(p.products_price) FROM products p left join orders_products op
I have this query select SUM(Qty) as Qty from WorkTbl group by Status having
I have this query: SELECT p.text,se.name,s.sub_name,SUM((p.volume / (SELECT SUM(p.volume) FROM phrase p WHERE p.volume
Query: SELECT SUM(ProductCost) FROM `tblBasket` GROUP BY ProductCode HAVING BasketSessionID = '3429782d79c68834ea698bb4116eef5e' Showing Error
Using the following query: SELECT sum(severity) as Score, DATE_FORMAT(LAST_UPDATE,%Y-%m) as score_date FROM missingpatches GROUP
I have a Query Script like this: SELECT View1.OrderDate,View1.Email,SUM(View1.TotalPayments) FROM dbo.View1 WHERE (View1.OrderStatus =
The following query works: SELECT SUM(sales), date FROM sales INNER JOIN exchange_rates USING(date) But
SELECT SUM(bytes),stamp_updated from acct where stamp_updated BETWEEN datetime('now', 'localtime','-7 hours') AND datetime('now', 'localtime') GROUP
$query = SELECT COUNT(t.id), SUM(t.num_replies) FROM threads AS t WHERE t.forum_id=$forum_id; $result = mysql_query($query);
If SELECT SUM(amount) FROM transactions ORDER BY order LIMIT 0, 50 sums the amount

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.