想要在一行中显示重复数据 [英] Wanted to show duplicate data in one row

查看:51
本文介绍了想要在一行中显示重复数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试检索一些数据,它会是这样的



Trying to retrive some data, it will come like this

OrderID  ReceiveDate ServiceProvided <br />
1001           12-12-2014  abc<br />
1001            12-12-2014  xyz





有任何选项显示这样的数据



there is any option to show the data like this

OrderID  ReceiveDate ServiceProvided(1) ServiceProvided(2) ...<br />
1001                 12-12-2014  abc                 xyz                ......





orderid并在一张表中收到,但服务提供的数据来自serviceprovided table。

我的意思它不是单一表格。





orderid and receivedate in one table but serviceprovided data from serviceprovided table.
what i mean is its not single table.

SELECT JobDetails.JobCode,JobDetails.ReceiptDate,JobDetails.DeliveryDate,JobDetails.CompletionDate,JobDetails.BranchName,JobDetails.FinalRemarks,
       CustomerDTL.CustomerName,CustomerDTL.MobileNumber,
       RepairDetails.Tech_Name,RepairDetails.Device_Condition,RepairDetails.Levels,
       RepairDetails.Repair_Remarks,
       PartsIssueDetails.ItemName,ItemMaster.ItemCode,PartsIssueDetails.SparePrice
From JobDetails
Inner Join CustomerDTL On
     JobDetails.JobCode=CustomerDTL.JobCode
Inner Join RepairDetails On
     JobDetails.JobCode=RepairDetails.JobCode
Inner Join PartsIssueDetails On
     JobDetails.JobCode=PartsIssueDetails.JobCode
Inner Join ItemMaster On
     PartsIssueDetails.ItemName=ItemMaster.ItemName
Where JobDetails.DeliveryDate Between @Date1 and @Date2 and JobDetails.BrandName=@Brand and JobDetails.BranchName=@Branch

推荐答案

要在一行中获取数据,您需要使用 PIVOT [ ^ ] - 这是关于这个主题的一篇很好的CP文章在SQL查询中使用Pivot的简单方法 [ ^ ]



作为 ServiceProvided 数据位于您需要的不同表中o使用加入 [ ^ ] - 这是另一篇有助于CP的文章 - SQL连接的可视化表示 [ ^ ]
To get the data in a single line you need to use PIVOT[^] - here is a good CP article on the subject Simple Way To Use Pivot In SQL Query[^]

As the ServiceProvided data is in a different table you will need to use JOIN[^] - here is another CP article that will help - Visual Representation of SQL Joins[^]


这篇关于想要在一行中显示重复数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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