CREATE PROCEDURE `get_client_rank`(IN user_type_cd VARCHAR(6),IN client_id INT)
BEGIN
set @mycnt = 0;
SELECT a.rank FROM (
SELECT t.id,(@mycnt := @mycnt + 1) as rank FROM clients t INNER JOIN user_points ut on t.id=ut.user_id where ut.user_type_cd=user_type_cd ORDER BY ut.points desc )
a where a.id=client_id ORDER BY id;
END
CREATE PROCEDURE `get_supplier_rank`(IN user_type_cd VARCHAR(6),IN supplier_id INT)
BEGIN
set @mycnt = 0;
SELECT a.rank FROM (
SELECT t.id,(@mycnt := @mycnt + 1) as rank FROM suppliers t INNER JOIN user_points ut on t.id=ut.user_id where ut.user_type_cd=user_type_cd ORDER BY ut.points desc )
a where a.id=supplier_id ORDER BY id;
END
CREATE PROCEDURE `get_cart_rank`(IN user_type_cd VARCHAR(6),IN cart_id INT)
BEGIN
set @mycnt = 0;
SELECT a.rank FROM (
SELECT t.id,(@mycnt := @mycnt + 1) as rank FROM cart t INNER JOIN user_points ut on t.id=ut.user_id where ut.user_type_cd=user_type_cd ORDER BY ut.points desc )
a where a.id=cart_id ORDER BY id;
END
BEGIN
set @mycnt = 0;
SELECT a.rank FROM (
SELECT t.id,(@mycnt := @mycnt + 1) as rank FROM clients t INNER JOIN user_points ut on t.id=ut.user_id where ut.user_type_cd=user_type_cd ORDER BY ut.points desc )
a where a.id=client_id ORDER BY id;
END
CREATE PROCEDURE `get_supplier_rank`(IN user_type_cd VARCHAR(6),IN supplier_id INT)
BEGIN
set @mycnt = 0;
SELECT a.rank FROM (
SELECT t.id,(@mycnt := @mycnt + 1) as rank FROM suppliers t INNER JOIN user_points ut on t.id=ut.user_id where ut.user_type_cd=user_type_cd ORDER BY ut.points desc )
a where a.id=supplier_id ORDER BY id;
END
CREATE PROCEDURE `get_cart_rank`(IN user_type_cd VARCHAR(6),IN cart_id INT)
BEGIN
set @mycnt = 0;
SELECT a.rank FROM (
SELECT t.id,(@mycnt := @mycnt + 1) as rank FROM cart t INNER JOIN user_points ut on t.id=ut.user_id where ut.user_type_cd=user_type_cd ORDER BY ut.points desc )
a where a.id=cart_id ORDER BY id;
END