search

Home  >  Q&A  >  body text

Most popular product titles to attract first-time buyers

<p>Suppose I have a table with a DateTime column called purchase_time and other order details (store_id, buyer_id, item_id, value) and I want to find what buyers purchased most often during their first purchase product name. </p> <p>So far I've done this, but how do I find the most popular items? </p> <pre class="brush:php;toolbar:false;">select store_id, from transactions where purchase_time in (select min(purchase_time) from transactions c1 group by c1.store_id);</pre></p>
P粉164942791P粉164942791453 days ago591

reply all(1)I'll reply

  • P粉848442185

    P粉8484421852023-09-02 09:36:41

    SELECT TOP 1 i.item_name
    FROM Transactions t
    INNER JOIN Items i ON i.item_id = t.item_id
    WHERE purchase_time = (select *, MIN(purchase_time) FROM Transactions)
    GROUP BY 1
    ORDER BY COUNT(*)  DESC

    reply
    0
  • Cancelreply