Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.2 kB
0
Indexable
Never
CREATE 
    ALGORITHM = UNDEFINED 
    DEFINER = `root`@`%` 
    SQL SECURITY DEFINER
VIEW `waorderaja`.`v_product_dash` AS
    SELECT 
        `p`.`id` AS `id`,
		`p`.`skuCode` AS `skuCode`,
        `p`.`barcode` AS `barcode`,
        `p`.`name` AS `name`,
        `p`.`accountId` AS `accountId`,
        `p`.`statusId` AS `statusId`,
        `p`.`price` AS `price`,
        `pc`.`categoryProductId` AS `subgategoryId`,
        `cp`.`name` AS `sub_category`,
        `cp`.`parentId` AS `categoryId`,
        `cp2`.`name` AS `category`,
        SUM(`od`.`qty`) AS `total_terjual`
    FROM
        (((((`waorderaja`.`product` `p`
        LEFT JOIN `waorderaja`.`product_category` `pc` ON ((`pc`.`productId` = `p`.`id`)))
        LEFT JOIN `waorderaja`.`category_product` `cp` ON ((`cp`.`id` = `pc`.`categoryProductId`)))
        LEFT JOIN `waorderaja`.`category_product` `cp2` ON ((`cp2`.`id` = `cp`.`parentId`)))
        LEFT JOIN `waorderaja`.`order_detail` `od` ON ((`od`.`productId` = `p`.`id`)))
        LEFT JOIN `waorderaja`.`order` `o` ON ((`o`.`id` = `od`.`orderId`)))
    GROUP BY `p`.`id` , `p`.`name` , `p`.`price` , `pc`.`categoryProductId` , `cp`.`parentId`
Leave a Comment