易截截图软件、单文件、免安装、纯绿色、仅160KB

求一条sql语句

有表 temp字段 prodid ,userid,endprice
记录如下
prodid,userid,endprice
 1 10 100
 1 11 200
 1 10 300
 2 11 200
 2 10 300
 2 12 400
 3 10 500
 3 11 600
 3 10 700
求用户对所以商品出价领先的记录 
上述如果我是10号用户则所求结果记录: 1 10 300(第三条记录),3 10 700(最后一条记录);两条记录
如果我是11号用户所求结果记录:没有记录
。。。。12..................: 2 12 400(第六条记录)

各位帮帮忙啊,谢谢

引用
SQL code
---测试数据---
if object_id('[temp]') is not null drop table [temp]
go
create table [temp]([prodid] int,[userid] int,[endprice] int)
insert [temp]
select 1,10,100 union all
select 1,11,200……

。。。

SQL code:
select
*
from
temp t
where
endprice=(select max(endprice) from temp where prodid=t.prodid)
and
userid=10



...

SQL code:
select *
from temp t
where endprice=(select top 1 endprice from temp where prodid=t.prodid order by endprice desc)
and userid=10
/*
prodid u


相关问答:

csv文件转换成sql导入到数据库,没有数据为何?

执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......

ASP链接SQL的简单登陆界面 - .NET技术 / ASP.NET

protected void btnLogin_Click(object sender, EventArgs e)
  {
  SqlConnection conn = new SqlConnection("Server = (local);user id = sa;pwd = 1;database = Login");
&nb ......

如何使用MySQL - MS-SQL Server / 基础类

刚刚接触MySQL,不知道该如何去查看数据,插入数据,创建数据库、表,用哪为前辈能指教一二?

MySQL 5.1参考手册

引用
兄弟你会结贴吗?
mysql 参考手册

baidu

MySQL官方文档 http://dev.mysql.com/doc ......

两句SQL并一句,有问题. - MS-SQL Server / 基础类

第一句:
select ht.gfdm,gfdm.gfmc,gfdm.lb ,sum(jh.htdj*jh.htsl)as je
from ht left join gfdm on ht.gfdm=gfdm.gfdm 
 join jh on ht.htbh=jh.hth 
and ht.htbh not like'del%' and ht. ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号