Aklıma ilk geldiği şekilde yazmaya çalıştım daha kolayı vardır belki ama, işinizi görebilir hocam
SELECT productId,( (SELECT count(*) FROM `soldProducts` GROUP BY product ORDER BY count(*) DESC LIMIT 1) * (SELECT price FROM `productInformation` WHERE productInformationID = (SELECT productInformationID FROM `product` WHERE productId = (SELECT product FROM `soldProducts` GROUP BY product ORDER BY count(*) DESC LIMIT 1) LIMIT 1)) ) as toplamSatis FROM product LIMIT 1
hocam cok tesekkür ettim calısmasa bile izlediginiz yol yardımcı oluyor.
Sahurlu gözlerle yazdım ben de bilmem çalışır mı
SELECT pi.price, count(*) FROM SOLDPRODUCTS sp
INNER JOIN PRODUCT p ON sp.product = productId
INNER JOIN PRODUCTINFORMATION pi ON pi.productInformationID = p.productInformationID
group by sp.product
ORDER BY count(*) DESC LIMIT 1
aynı sekilde hocam cok tesekkür ediyorum.
Veritabanını oluşturup test ettim hocam çalışıyor, hayırlı sahurlar
Select a.adet * c.price as tutar From (
Select Top 1
max(product) as product,
count(*) as adet ,
ROW_NUMBER() OVER (ORDER BY count(*) desc) as row
from soldProducts
group by product
order by count(*) desc) As a
inner join product as b on a.product = b.productId
inner join productInformation as c on c.productInformationID = b.productInformationID
hocam ben postgresql kullanıyorum bunu belirtmem gerekliydi sanırım ben de bu yuzden mi calısmadı acaba. max kısmında bir hata aldım.
çok teşekkür ederim yardımınız için