使用具有不同列和行的SQL Server合并一个表中的数据 [英] merging of data in one table using sql server with different columns and rows
问题描述
ID |名称|地址|状态|日期
1 | AJ |新泽西州|好的2013年6月9日
2 | AJ |新泽西州|优秀| 2013年6月10日
我的问题是我如何合并数据尽管id是唯一的但是因为状态是变化所以我希望新的数据会被查看,但我也有这个问题
申请人数量姓名
1 | AJ
2 | AJ
我希望它会成为一个,因为它会发生在这个插图中将是
申请人数量|姓名
1 | AJ
提前谢谢
听起来像你的桌子设计是不是很划伤。
也许你需要一张这样的桌子:
申请ID,姓名,地址......
和另一张表格如下:
ApplicantStatusID,ApplicantID,Status,日期
然后您可以从第二个表中获取最新的状态日期,并将其链接到第一个表中的详细记录。
guys can you help to figure out what code should i use by merging a data in one table in sql server procedure this is the scenario
ID | Name | Address | Status | Date
1 | AJ | New Jersey | GOOD | jun 9 2013
2 | AJ | New Jersey | EXCELLENT | jun 10 2013
my question is how can i merge the data though the id is unique but as status is change so i expect the new data will be viewed but im having also a problem with this
Number of applicant | Name
1 | AJ
2 | AJ
which i expect it to be one as it will happen to this illustration will be
Number of applicant | Name
1 | AJ
thanks in advance
Sounds like your table design isn't quite up to scratch.
Perhaps you need one table like this:
ApplicantID, Name, Address...
And another table like this:
ApplicantStatusID, ApplicantID, Status, Date
Then you could get the latest status date from the second table and link it to the details record in the first table.
这篇关于使用具有不同列和行的SQL Server合并一个表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!