本文介绍了我想要前3名的麸名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

orderdetails
orderdatailsid | order_master_id branchname category branchid
1				112				vellore		nad		123
2				112				vellore		hu		123
3				113				chennai		ji		121
4				112				vellore		hi		123
5				134				tvl			ui		145
6				134 				tvl		jo		145
7
masterdetails
ordermasterid    userid
112              12
113		 13
134	         14




SELECT T.*,S.* FROM
(
  Select TD.category_name,TD.branch_name,TM.created_date,TM.user_id,TD.order_details_id,TD.branch_id
  From tbl_orderdetails TD Inner Join tbl_ordermaster TM ON
    TD.order_master_id = TM.ordermasterid
  Where TM.user_id='12'
) T Inner Join
(
SELECT M.branch_name,Max(M.No_Of_Branch) FROM
  (
    Select T1.branch_name,Count(T1.branch_name) As No_Of_Branch
    From tbl_orderdetails T1 Inner Join tbl_ordermaster T2 ON
         T1.order_master_id = T2.ordermasterid
    Where T2.user_id='12'
    Group By T1.branch_name
  ) M Group By M.branch_name
) S On S.branch_name = T.branch_name





i使用此代码但未获得适当的结果



i used this code but not getting appropriate result

推荐答案

这篇关于我想要前3名的麸名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 15:08