我怎么写这个..我有一个表“公司”,有一列“大小”。大小引用枚举。当“大小”列是:
1 = 15
2 = 30
3 = 50
4 = 100
5 = 250
换句话说,我的表格将公司规模显示为 1、2、3、4 或 5。而 1 实际上是公司规模 15。
这是更大查询的一部分:
SELECT COUNT(DISTINCT(ID)) AS 'Total # of Opps', AVG(Size*?) AS 'AverageEstimatedCompanySize'
FROM persontable AS POJT INNER JOIN opportunity
ON POJT.ID = opportunity.id
WHERE opportunity.TimeStamp >= '2012-01-01' AND opportunity.TimeStamp <= '2012-12-31' AND POJT.JobTitleID IN
(SELECT Id
FROM job
WHERE CategoryID IN
(SELECT id
FROM job_category
WHERE name IN ('Sc', 'Ma', 'Co', 'En', 'Tr')))