These are my tables
Table1
- price
- city_category_id
- city_product_id
Here are three rows"
price | city_category_id | city_product_id
------+------------------+--------------------------
1500 | CHDELCLAPTOPDELL | CHDELCLAPTOPDELLVOSTR8
1200 | CHDELCLAPTOPDELL | CHDELCLAPTOPDELLVOSTR816
1000 | CHDELCLAPTOPDELL | CHDELCLAPTOPDELLVOSTR816
Here I have to find firstly distinct product_name and then select min price of the distinct elements.I want output as CHDELCLAPTOPDELLVOSTR816 and 1200 and CHDELCLAPTOPDELLVOSTR816 and 1000
.
QUERY
select min(price)
from sellers_product
where city_product_id=
(
select distinct city_product_id
from sellers_product
where city_category_id='CHDELCLAPTOPDELL'
)
ERROR
I know why this error is coming because there are more than 1 rows returned by subquery but is there any way to get the desired output using only 1 query.
city_product_id=
tocity_product_id IN (
– Abhik Chakraborty