在单个查询字符串中运行top并按命令分组 [英] run top and group by command in a single query string

查看:72
本文介绍了在单个查询字符串中运行top并按命令分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




在我的项目中,我有不同的产品,我现在要为特定客户输入价格,我要在另一个日期更改价格,我也想按以下方式查看最后三个价格更新

产品名称-------- Date1 -------- Date2 -------- Date3

产品1 ------------价格--------价格--------价格
product2 ------------价格--------价格--------价格
.
.
.
.
.


我该怎么办????




In my project i have different products and i am inserting prices for particular customers now i am changing the prices on another date also i want to see the last three price updates in following manner

product name-------- Date1--------Date2--------Date3

product1------------ price--------price--------price
product2------------ price--------price--------price
.
.
.
.
.


how can i do this ????

推荐答案

从您的示例中看来,您将需要编写PIVOT查询.以下链接说明了样本PIVOT查询
http://www.simple -talk.com/blogs/2007/09/14/pivots-with-dynamic-columns-in-sql-server-2005/ [
From your example it looks like you would need to write a PIVOT query. Samples PIVOT query is explained in the below link
http://www.simple-talk.com/blogs/2007/09/14/pivots-with-dynamic-columns-in-sql-server-2005/[^]


这篇关于在单个查询字符串中运行top并按命令分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆