There are 2 tables - shop_users and shop_users , it is necessary to extract all users with a non-empty shop_users and sort them by the number of items in it. The result must necessarily give shop_users.*
shop_users ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `password` varchar(55) NOT NULL, ... ) shop_cart ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `item_id` int(11) NOT NULL, `count` int(11) NOT NULL, ... )