SQL:使用来自具有相同列名的两个表中的数据......等等
我想做的是:
一月表
尖端编号:1、2、3
电流系数:.123、.140、.045
Current Factor: .123, .140, .045
二月表
尖端编号:1、2、3
电流系数:.184、.163、.033
Current Factor: .184, .163, .033
然后是 FEB 表中的一个新列,用于查找每个 CUSIP 数字的 Feb 因子/jan 因子的值:
Then a new column in the FEB table that finds the value of the Feb factor/jan factor for each CUSIP number:
=.123/.184
=.140/.163
等等.
到目前为止,这是我从上个月提取的因素并将其显示在二月表下方
This is what I have so far which pulls the factor from the previous month and displays it below the Feb Table
SELECT [CURRENT FACTOR]
FROM DBO.mbs012013, DBO.mbs022013
WHERE DBO.mbs012013.[CUSIP NUMBER] = DBO.mbs022013.[CUSIP NUMBER]
推荐答案
试试这个:
SELECT b.[CUSIP NUMBER],
b.[CURRENT FACTOR],
a.[CURRENT FACTOR]/b.[CURRENT FACTOR] MyNewFieldName
FROM DBO.mbs012013 a, DBO.mbs022013 b
WHERE a.[CUSIP NUMBER] = b.[CUSIP NUMBER]
相关文章