本文介绍了Combaine两张桌子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Select Row_Number() over (order by FeedType) SNo, FeedType from k_FPS_FeedType declare @DaVal as datetime --111 will return yyyy/MM/dd --101 will return MM//dd/yyyy set @DaVal = convert(datetime, convert(varchar(25), DATEADD(d,-1,GETDATE()), 111)) select rateperkg from K_FS_FeedMrpDetails where date = @DaVal
这些是表格,但我尝试在一张表中显示.. 怎么样?添加到一个表中,输出就像
These are tables ,but i try to it shows in one table.. how can add in one table,out put like
SNO FeedType Yeserdayrates 1 Breeder 32 2 Breeder1 25推荐答案
除非两个表之间有链接(你没有显示)然后没有,你可以' t - 你需要有一个共同的列才能做到这一点。 例如: Unless there is a link between the two tables (which you don't show) then no, you can't - you need to have a column in common in order to do that. For example: tabInvoice ID Int, Identity INo Iny CompID Int
tabCompany ID Int CoName NVARCHAR(200)
tabInvoice:
tabInvoice:
ID INo CompId 1 10001 1 2 10002 1 3 10003 2tabCompany
tabCompany
ID CoName 1 Jones Supplies 2 Mikes Bits 3 Gary Sells It
SELECT i.ID, i.INo, c.CoName FROM tabInvoice i JOIN tabCompany c ON i.CompId=c.CoName
将返回:
Will return:
ID INo CompName 1 10001 Jones Supplies 2 10002 Jones Supplies 3 10003 Mikes Bits如果没有您桌子的详细信息,我们无法准确了解您的需求。 BTW:什么是数据转换的东西?很奇怪......
Without the detail for your tables, we can't be precise about what you need. BTW: What the heck is that data conversion stuff for? Very odd...
尝试UNION。 technet.microsoft/en-us/library/ms180026.aspx [ ^ ] Try UNION. technet.microsoft/en-us/library/ms180026.aspx[^]
更多推荐
Combaine两张桌子?
发布评论