0

I'm attempting to execute the following query and I get the above error. Any ideas?

session.CreateQuery("SELECT SUM(NumberHead) AS numberhead " +
                     "FROM Purchase "
                     +"INNER JOIN Lot " 
                     + "ON Purchase.FeedLot = Lot.Id "
                     + "WHERE Purchase.CohortState = 0").List();
Fabii
  • 3,820
  • 14
  • 51
  • 92

1 Answers1

1

try this

SELECT SUM(purchase.NumberHead) AS numberhead FROM Purchase purchase INNER JOIN Lot lot ON purchase.FeedLot = lot.Id WHERE purchase.CohortState = 0
spiritwalker
  • 2,257
  • 14
  • 9
  • how do entity class look like? any explicit relationship between Purchase and Lot? if there is OneToOne or OneToMany between entities, If there is, then no need to put **Purchase.FeedLot = Lot.Id** in query. And the query would look like this **SELECT SUM(purchase.NumberHead) AS numberhead FROM Purchase purchase INNER JOIN purchase.FeedLot WHERE purchase.CohortState = 0** – spiritwalker Feb 14 '13 at 02:46
  • A lot can have many purchases, a purchase can only belong to one lot – Fabii Feb 14 '13 at 15:36
  • have you tried this one **SELECT SUM(purchase.NumberHead) AS numberhead FROM Purchase purchase INNER JOIN purchase.FeedLot WHERE purchase.CohortState = 0** – spiritwalker Feb 14 '13 at 23:22