I have tables
- Product (
ID, CategoryID, ...) - Category (
ID, Name, ..), and - FieldValue (
ID, ProductID, Value...)
This is my query:
select count(*) from Product as p, FieldValue as v, Category c
where c.ID = 3 and v.Value="XXX"
and p.ID = v.ProductID and c.ID=p.CategoryID
group by p.ID
My intention is obvious to count the number of products with certain criteria.
The problem is NHibernate is returning me a list of numbers instead of a single number with the number of products. What am I missing?
Any help is greatly appreciated.
You have to remove the
group byWith the statment you have, you get one count for each productID, instead of a count for all products.
If you want to count the number of products, replace the
count(*)withcount(distinct p.id)(still withoutgroup by)