// Product wise Stock
CREATE VIEW product_stocks AS
SELECT purchase_details.product_id, 
	purchase_details.category_id, 
	purchase_details.brand_id,
	purchase_details.unit_id,
	products.re_order_label,
 SUM(purchase_details.now_stock) as product_stock
 FROM purchase_details,products WHERE purchase_details.now_stock > 0 and purchase_details.product_id = products.id 
GROUP by purchase_details.product_id 

// warehouse wise stock
CREATE VIEW warehouse_stocks AS
SELECT purchase_details.warehouse_id,
	purchase_details.product_id, 
	purchase_details.rack_no, 
	purchase_details.category_id, 
	purchase_details.brand_id,
	purchase_details.unit_id,
	products.re_order_label,
 SUM(purchase_details.now_stock) as product_stock
 FROM purchase_details,products,warehouses WHERE purchase_details.now_stock > 0 and purchase_details.product_id = products.id 
GROUP by purchase_details.product_id 

// Purchase Stock Table

CREATE VIEW purchase_stocks AS
 SELECT purchase_details.*, products.product_name FROM products,purchase_details 
	WHERE purchase_details.now_stock > 0
		AND purchase_details.product_id = products.id

/*----------------------------------------*/

SELECT 
	SELECT COUNT(items.id) as item_total, 
		COUNT(products.id) as product_total,
		COUNT(requisitions.id) as requisitions_total
	 FROM items,products,requisitions
