<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 89,  comments - 98,  trackbacks - 0
    給下面這樣的一個表記錄:

    ------------------------------------

    購物人????? 商品名稱???? 數(shù)量
    A??????????? 甲????????? 2
    B????????????乙????????? 4
    C??????????? 丙????????? 1
    A??????????? 丁????????? 2
    B????????????丙????????? 5


    給出所有購入商品為兩種或兩種以上的購物人記錄

    posted on 2006-09-19 10:07 水煮三國 閱讀(3076) 評論(11)  編輯  收藏 所屬分類: Sybase

    FeedBack:
    # re: 貼一道SQL面試題,希望大家相互討論
    2006-11-02 16:10 | 希望男孩
    在三個表中,其中第一個表  回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論
    2006-11-02 16:14 | 希望男孩
    抱歉!剛才測試一下本網(wǎng)站是否好用!現(xiàn)在出個讓大家討論的sql語句

    a b c 三個字段有可能重復(fù)







    數(shù)據(jù)如下:







    a b c d e



    ---------- ---------- ---------- ----------- -----------



    a a a 1 2



    a a a 1 2



    a a a 1 2



    a a a 1 2



    a a a 1 2



    b b b 3 3



    b b b 3 3



    b b b 3 3



    b b b 3 3



    b b b 3 3



    b b b 3 3



    b b b 3 3



    c c c 4 4



    d d d 5 5



    d d d 5 5







    問題一: 現(xiàn)在要把三個字段有重復(fù)的數(shù)據(jù)提出來.



    問題二: 合并表中的數(shù)據(jù),比如



    a a a 1 2



    a a a 1 2



    a a a 1 2



    a a a 1 2



    a a a 1 2



    這五條紀(jì)錄要合并成一條



    a a a 5 10


      回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論
    2007-11-16 14:56 | janrick
    select t.name
    from
    (
    select max(購物人) as name,count(購物人) as cnt
    from chanpin
    group by 商品名稱
    ) t
    where t.cnt >=2  回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論
    2008-06-05 07:00 | beebe
    select t.name,t.cnt from(
    select userName as name,count(userName) as cnt
    from exam1
    group by userName)t
    where t.cnt>=2  回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論
    2009-02-20 11:58 | 暢暢暢
    +---------+---------+----------+
    | cp_name | cp_kind | cp_count |
    +---------+---------+----------+
    | A | a | 1 |
    | A | c | 2 |
    | A | t | 1 |
    | B | t | 1 |
    | B | a | 2 |
    | C | d | 1 |
    | D | c | 2 |
    | C | d | 3 |
    +---------+---------+----------+
    上面兩道答案明顯錯誤,題目的意思是返回購買“兩種或兩種商品以上“的客戶信息。
    正確答案應(yīng)該是:
    select t.cp_name,t.cnt from (select cp_name,count(distinct cp_kind) as cnt from chanpin group by cp_name) t where t.cnt>=2;
      回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論
    2009-03-21 23:53 | liweibird
    @暢暢暢
    select * from T1
    where customer_name in
    (select customer_name
    from T1 as b
    group by customer_name
    having count(distinct trade_name)>=2)  回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論
    2009-05-21 12:57 | luguo
    select * from sales as t1 where exists
    (
    select t2.customerName from sales as t2 where t1.customerName = t2.customerName
    group by t2.customerName
    having (count(t2.customerName) >= 2)
    )  回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論[未登錄]
    2009-08-22 10:06 | allan
    @暢暢暢
    這個不是一句就夠了么。
    select cp_name,count(distinct cp_kind) cnt from tableName group by cp_name having cnt >= 2;  回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論
    2009-09-06 01:35 | poplau
    tableName:test
    person gName scount
    A 甲 2
    B 乙 4
    C 丙 1
    A 丁 2
    B 丙 5
    給出所有購入商品為兩種或兩種以上的購物人記錄

    select person,count(gName) from test GROUP BY person having count(gName)>=2

    select * from (select person,count(gName) as gc from test GROUP BY person) as a where a.gc>=2   回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論
    2010-03-16 21:53 | hhw
    樓上回答的第一題都是錯的。如果在加數(shù)據(jù)肯定不行。下邊我把正確的寫一下
    注意了:第一題
    select s.ren from (select distinct(shangpin), ren from tt group by ren , shangpin) s group by s.ren having count(s.ren)>=2
      回復(fù)  更多評論
      
    # re: 貼一道SQL面試題,希望大家相互討論
    2010-05-12 13:57 | NA
    For SQL SERVER:
    declare @t3 table (buyer nvarchar(50),goods nvarchar(50),qty int)
    insert into @t3 values('A','甲',2)
    insert into @t3 values('A','甲',3)
    insert into @t3 values('B','乙',4)
    insert into @t3 values('C','丙',1)
    insert into @t3 values('C','丙',2)
    insert into @t3 values('A','丁',2)
    insert into @t3 values('B','丙',5)
    select * from @t3

    select t1.buyer,t1.goods,SUM(t1.qty) from @t3 t1 inner join @t3 t2 on t1.buyer=t2.buyer and t1.goods <> t2.goods
    group by t1.buyer,t1.goods  回復(fù)  更多評論
      
    <2009年5月>
    262728293012
    3456789
    10111213141516
    17181920212223
    24252627282930
    31123456

    常用鏈接

    留言簿(4)

    隨筆分類(85)

    隨筆檔案(89)

    文章分類(14)

    文章檔案(42)

    收藏夾(37)

    java

    oracle

    Sybase

    搜索

    •  

    積分與排名

    • 積分 - 210747
    • 排名 - 266

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 一级毛片在线观看免费| 大片免费观看92在线视频线视频| 中文字幕不卡免费视频| 亚洲AV无码资源在线观看| 韩国免费一级成人毛片| 亚洲综合精品伊人久久| 欧美三级在线电影免费| 亚洲大码熟女在线观看| 精品免费视在线观看| 国产AV无码专区亚洲精品| 日韩精品在线免费观看| 亚洲视频在线一区二区三区| 91成人免费观看网站| 国产亚洲一区区二区在线 | 9277手机在线视频观看免费| 久久久综合亚洲色一区二区三区| 污污网站免费观看| 亚洲一区二区三区高清不卡| 麻豆国产入口在线观看免费| 污视频网站在线免费看| 亚洲色大成网站WWW久久九九| 美女视频黄免费亚洲| 久久免费公开视频| 亚洲jjzzjjzz在线观看| 亚洲AV无码专区日韩| 中文字幕免费人成乱码中国| 亚洲国产成人精品不卡青青草原| 青娱乐免费视频在线观看| 国产亚洲精品第一综合| 亚洲精品成人片在线播放| 免费观看国产网址你懂的| 蜜芽亚洲av无码一区二区三区| 国产成人精品日本亚洲专区| 一级毛片不卡片免费观看| 亚洲精品无码中文久久字幕| 亚洲精品和日本精品| 99久久国产免费-99久久国产免费| 在线观看亚洲成人| 国产成在线观看免费视频| 真人无码作爱免费视频| 日本久久久久亚洲中字幕|