0

MySQL GetCurrentRating(cid, m)

Write a stored function GetCurrentRating(cid, m) which returns the current rating of model m by customer cid. If the cid has not rated m then this function should return NULL. This applies both in the case when cid has never rated m as well as in the case when cid has rated m but then cancelled their rating.

28th Nov 2021, 5:23 PM
A.K2002
2 Respostas
0
Post your attempt here
28th Nov 2021, 5:26 PM
MATOVU CALEB
MATOVU CALEB - avatar
0
my attempt: DELIMITER // CREATE FUNCTION GetCurrentRating(cid, m) RETURNS INTEGER DETERMINISTIC NO SQL READS SQL DATA BEGIN DECLARE v_CID_count INTEGER; SELECT COUNT(*), Rating_of_model INTO v_CID_count FROM CUSTOMER C; IF ( CID rated m then RETURN m_rating else IF ( (CID NOT rated m then RETURN NULL) else CANCELLED ); END// DELIMITER ;
28th Nov 2021, 5:28 PM
A.K2002