Combaine两张桌子? [英] Combaine Two tables?
本文介绍了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 2
tabCompany
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。
http://technet.microsoft.com/en-us/library/ms180026.aspx [ ^ ]
Try UNION.
http://technet.microsoft.com/en-us/library/ms180026.aspx[^]
这篇关于Combaine两张桌子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文