货物的查询
来源:互联网 发布:简明python教程中文版 编辑:程序博客网 时间:2024/04/28 09:14
这是SQL Server数据库第一个表Product表,字段有:ProductId ProductName第二表ProductSKU表,字段有:ProductId SKU ReleaseDate他们是一对多的关系即一个Product可以有多个SKU,但至少有一个现在要解决的问题是:当向product表加入一条数据的时候,也向ProductSKU表加入了一条数据但日后会不断为一个Product再添加SKU,也就出现了一个Product有多个SKU我想提取最新的10条含有至少2个SKU的Product信息只是Product信息(ProductId,ProductName)不需要ProductSKU信息,并且在结果里不可以出现重复的Product信息
---------------------------------------------
并且排序方式是按照ProductSKU表的ReleaseDate字段进行排序
请问如何写这个SQL语句?
select * from Product where ProductID in (select top 10 ProductId from ProductSKU group by ProductID having count(1)>1 order by max(ReleaseDate) desc;
select a.productId,a.ProductName from Product a inner join ProductSKU b on a.productID = b.productID group by a.product,a.ProductName having count(b.productId) > 1;
select a.* from t1 a,(select top 10 pid,rq = max(ReleaseDate) from t2 group by pid having count(*) > 1 order by max(ReleaseDate) desc) b;
- 货物的查询
- 货物的损耗的设计
- 货物进出口的实务流程
- 上的货物和发放
- 库存中货物超期的天数
- 传送带装载货物的最优解问题
- 一种基于启发式算法的货物装载问题的研究
- sap货物移动相关的bapi(MIGO/MB1A)
- 最多能运送到的货物数量 Camel and Bananas
- bnuoj 20950 沉重的货物 (最小生成树)
- MM模块-货物移动对标准价的影响
- 读取生产订单 记入文档的货物移动明细
- 如何运送最多的货物(0-1背包)
- bnuoj 20950 沉重的货物 (最小生成树)
- SAP 货物移动 BAPI 的简单使用 BAPI_GOODSMVT_CREATE
- VL09 不能取消来自分散系统的货物移动
- 这是一个简单的货物管理系统。
- 货物管理
- 页面无限跳转间如何保存页面状态(1)
- Nutch -0.8.1 摘要高亮出错分析
- 服务器端控件使用客户端脚本
- 页面无限跳转间如何保存页面状态(2)
- 偶的构件
- 货物的查询
- Linux 常见问题 1000 个详细解答
- .net多语言和数据集内多数据表的处理(2)
- Effective C#-Working with Strings (翻译)
- 完全卸载Oracle数据库的方法(转)
- 内蒙古森林火线运兵直升机坠毁14人伤
- .net入门之VB篇:Visual Basic.Net中的文件操作(一)
- 祝贺SharpDevelop中文站开通,让我们共同来挖掘#devel
- ADO.NET入门(1)