select m.BigClassName , n.* from 类别表 m,
(
select t.* from 商品表 t where where IsHot = 1 and AddTime in (select top 4 AddTime from 商品表 where IsHot = 1 and BigClassId = t.BigClassId)
) n
where m.BigClassId = n.BigClassId
order m.BigClassId , n.AddTime desc
解决方案 »
- 看了邹老大的数据库备份和还原的代码,有个疑问,求释疑~
- 如何做一个做事有计划的人?
- 如下更新查询该如何写
- 分区表-非聚集索引
- 谁能给一个包括事务的在游标中使用存储过程的例子代码?
- 急: SQL 怎么实现,加上一行查出的值??例:0+100,100+200```
- 请问SQL 2000企业版和标准版可以做单机使用吗?
- BULK INSERT命令,当文件里的日期为2005-12-8 00:00:00倒入不了,为2005-12-08 00:00:00可以,有什么办法呀!!!
- 如何用sql语句修改sqlserver数据库结构?
- 字符串处理问题?谢谢
- MSSQL2005 BLOB字段的问题
- 用ADO查询, 数据表来自两个服务器如何做
select m.BigClassName , n.* from 类别表 m,
(
select t.* from 商品表 t where IsHot = 1 and AddTime in (select top 4 AddTime from 商品表 where IsHot = 1 and BigClassId = t.BigClassId)
) n
where m.BigClassId = n.BigClassId
order m.BigClassId , n.AddTime desc
from 商品表 a,类别表 b
where a.bigclassid=b.bigclassid and a.productid in
(select top 4 productid from 商品表 c
where a.bigclassid=c.bigclassid and c.ishot=1 order by c.bigclassid,c.addtime desc)
order by a.bigclassid,a.addtime
--上面多了个where
select m.BigClassName , n.* from 类别表 m,
(
select t.* from 商品表 t where IsHot = 1 and exists(select top 4 * from 商品表 where IsHot = 1 and BigClassId = t.BigClassId)
) n
where m.BigClassId = n.BigClassId
order m.BigClassId , n.AddTime desc
exists的效率比in 要高