我如何通过按降序排列排序和按升序排序价格

我希望我的查询将返回行,例如按评分先排序,然后按价格排序

我希望通过按小时率对ASC进行均值评估来按第一个desc进行两级订购

如果价格我知道多个同质的简单订单不能帮助我达到我的期望,但此查询为我提供了按两列按混合值随机排序的记录,但我目前还不知道如何获取记录

SELECT
   `users`.`id` AS `refId`,
   `tutor_subjects`.`id`,
   `tutor_subjects`.`user_id`,
   `users`.`role_id`,
   `users`.`email_verified_at`,
   `user_profiles`.`photo`,
   `user_profiles`.`gender`,
   `user_profiles`.`first_name`,
   `user_profiles`.`last_name`,
   `user_profiles`.`overview_video_link`,
   `user_profiles`.`overview_video_file`,
   `user_profiles`.`tag_line`,
   `user_profiles`.`profile_slug`,
   `user_profiles`.`hourly_rate`,
   `user_profiles`.`city`,
   `user_profiles`.`state`,
   `cities`.`name` AS `city_name`,
   `states`.`name` AS `state_name`,
   `user_profiles`.`about_me`,
   (
   SELECT
       COALESCE(AVG(course_reviews.rating),
       0)
   FROM
       course_reviews
   WHERE
       course_reviews.tutor_id = tutor_subjects.user_id
   LIMIT 1
) AS average_rating,(
SELECT
   COUNT(*)
FROM
   course_reviews
WHERE
   course_reviews.tutor_id = tutor_subjects.user_id
LIMIT 1
)
FROM
   `tutor_subjects`
INNER JOIN
   `users`
ON
   `users`.`id` = `tutor_subjects`.`user_id`
INNER JOIN
   `user_profiles`
ON
   `user_profiles`.`user_id` = `tutor_subjects`.`user_id`
LEFT JOIN
   `cities`
ON
   `cities`.`id` = `user_profiles`.`city`
LEFT JOIN
   `states`
ON
   `states`.`id` = `user_profiles`.`state`
LEFT JOIN
   `tutor_grades`
ON
   `tutor_grades`.`user_id` = `tutor_subjects`.`user_id`
WHERE
   (
       `category_id` IN(182) OR `categories_sub_id` IN(182)
   ) AND EXISTS(
   SELECT
       *
   FROM
       `users`
   WHERE
       `role_id` = 3 AND users.id = tutor_subjects.user_id
) AND(
   `gender` = 'Male' OR `gender` = 'Female'
) AND EXISTS(
SELECT
   *
FROM
   `tutor_locations`
WHERE
   tutor_locations.user_id = tutor_subjects.user_id
) AND EXISTS(
SELECT
   *
FROM
   `tutor_locations`
WHERE
   `lesson_mode` IN(2, 0, 1) AND tutor_locations.user_id = tutor_subjects.user_id
)
GROUP BY
   `tutor_subjects`.`user_id`
ORDER BY
   `average_rating`
DESC
LIMIT 10 OFFSET 0

它运行不正常,它显示混合记录,不是我希望按小时率对ASC进行均值评估,从而由第一个desc进行两级排序

任何想法我怎么能达到

评论