高分求一条sql语句。(200分)

  • 主题发起人 主题发起人 yunxi126
  • 开始时间 开始时间
Y

yunxi126

Unregistered / Unconfirmed
GUEST, unregistred user!
buyer_no &nbsp; &nbsp;d1 &nbsp; &nbsp;d2 &nbsp; &nbsp;d3 &nbsp; &nbsp;d4 &nbsp; d5 &nbsp; &nbsp;<br>b1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B* &nbsp; &nbsp; &nbsp;<br>b1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>b2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B<br>b2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B <br>b3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BE<br>变成<br>buyer_no &nbsp; &nbsp;d1 &nbsp; &nbsp;d2 &nbsp; &nbsp;d3 &nbsp;d4 &nbsp; d5 <br>b1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B<br>b2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B<br>b3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BE<br><br>空的地方的值都是null
 
我的数据库是postgreSQL..和sql2000差不多。但有些差别。好像不支持top 1如<br>select top 1 * from table所以最好别用top,游标也没有。最好用子查询
 
沉了。顶一下,各位。快来回一下啊。
 
这不是太容易了么<br>select buyer_no, <br>&nbsp; &nbsp; &nbsp; &nbsp;max(d1) as d1, <br>&nbsp; &nbsp; &nbsp; &nbsp;max(d2) as d2, <br>&nbsp; &nbsp; &nbsp; &nbsp;max(d3) as d3, <br>&nbsp; &nbsp; &nbsp; &nbsp;max(d4)as d4, <br>&nbsp; &nbsp; &nbsp; &nbsp;max(d5) as d5<br>from t1<br>group by buyer_no<br>order by buyer_no
 
lvxq答案正确 ,我验证过,有效!
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部