How to Use Sub Query In SQL

SELECT 
    od.`product_id`,
    SUM(od.`origianl_quantity`) AS total_quantity,
    (SELECT pro.`name` FROM products AS pro WHERE pro.`id` = od.`product_id`) 
        AS product_name 
FROM order_details AS od 
        GROUP BY od.`product_id`  ORDER BY total_quantity DESC

Popular posts from this blog

SQL In Static Id Wise Record Skip After Show Result