Jump to content

how to select the most frequent value and link it to another table

- - - - -

  • Please log in to reply
1 reply to this topic

#1
irfan_s

irfan_s

    Newbie

  • Members
  • PipPip
  • 25 posts
Posted Image

That is the query, and I get the error that pcnr has more meanings. My tables look like this:

Posted Image

The query is:

Get the name of the category that has the most products in it.

What is wrong with my query?

TY

#2
irfan_s

irfan_s

    Newbie

  • Members
  • PipPip
  • 25 posts
OK ty anyway. Here is the solution:

select result.PCName, max(result.product_sum) from (select ProductCategory.PCName as PCName,
count(*) as product_sum from Product, ProductCategory where ProductCategory.PCNr = Product.PCNr
group by Product.PCNr) as Result;




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users