1樓:匿名使用者
上面的回答真是太好了,不過合併下就完全達到你的要求了.
select
hobby1+','+hobby2 as hobby,nfrom (
select t1.hobby hobby1,t2.hobby hobby2,count(*) n
from test155 t1 inner jointest155 t2 on t1.name=t2.name and t1.hobby
group by t1.hobby,t2.hobby)torder by n desc
2樓:傳說中的鷹王
select t1.hobby hobby1 ,t2.hobby hobby2,count(*) n
from test t1 inner jointest t2 on t1.name=t2.name and t1.hobby
group by t1.hobby,t2.hobbyorder by n desc
3樓:
--這樣應該可以, 查出來結果順序和你不是太一樣select t1.hobby, t2.hobby, count(*)
from test t1
join test t2 on t1.name = t2.name and t1.hobby < t2.hobby
group by t1.hobby, t2.hobbyorder by t1.hobby, t2.hobby
sql語句寫法(sum和count)
sql迴圈語句 declare i int set i 1 while i 30 begin insert into test userid values i set i i 1 endwhile 條件 begin 執行操作 set i i 1 endwhile 設定重複執行 sql 語句或語句塊的...
關於sql的面試題求高手解答,sql問題,求高手解答
題目貼錯了吧 求每個du部門每個員工的最低工資與最高zhi工資每個人的工dao資不就1個麼,既是最高版 也是最低,嘿嘿 估計是求權部門的最高和最低工資 select select depname from depwhere dep.depid emp.depid asdepname,max pay ...
各國「我愛你」的寫法,求各個國家的「我愛你」的寫法,注意是寫法
漢語 我愛你 英語 i love you 法語 je t aime je t adore 德語 ich liebe dich 俄語 ya vas iyublyu,ya tibia lyublyu 韓國語 求各個國家的 我愛你 的寫法,注意是寫法 英文 i love you 俄文 韓文 日文 愛 泰文...