Get Last record of customer without group by. get last subscription record of each customer Mysql

Published: 16 February 2023
on channel: Coders Gateway - Web Tech solutions
29
1

Get Last record of each customers without group by. get last subscription record of each customer Mysql without sub query or Max

===================================================
Change [LESS THAN SYMBOL] = to less than symbol before run
===================================================

-- by id
SELECT
CURDATE() AS Today_date, t1.*, IF(
t1.end_of_subscription [LESS THAN SYMBOL] CURDATE(), 'Expired', 'Active') AS `Status`
FROM
`subscription_transaction` t1
LEFT JOIN `subscription_transaction` t2 ON
t1.customer_id = t2.customer_id AND t1.id [LESS THAN SYMBOL] t2.id
WHERE
t2.id IS NULL
ORDER BY
t1.customer_id,
t1.id;

-- By date

SELECT
CURDATE() AS Today_date, t1.*, IF(
t1.end_of_subscription [LESS THAN SYMBOL] CURDATE(), 'Expired', 'Active') AS `Status`
FROM
`subscription_transaction` t1
LEFT JOIN `subscription_transaction` t2 ON
t1.customer_id = t2.customer_id AND t1.`end_of_subscription` [LESS THAN SYMBOL] t2.`end_of_subscription`
WHERE
t2.id IS NULL
ORDER BY
t1.customer_id,
t1.id;


Watch video Get Last record of customer without group by. get last subscription record of each customer Mysql online without registration, duration hours minute second in high quality. This video was added by user Coders Gateway - Web Tech solutions 16 February 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 29 once and liked it 1 people.