隐藏结果集中的列SQL选择

时间:2016-07-17 05:31:40

标签: sql

我想隐藏第二次选择显示结果的EMPNO结果,因为我已经在第一次选择SO,任何想法?

   select *from
(select M.EMPLOYEE_NUMBER,count(M.EMPLOYEE_NUMBER)as empnumcon,sum(C.MEMBER_PAID_AMOUNT)
from CPMS.ABDULLAH_MEMBERS M,CPMS.ABDULLAH_EMPLOYMENTS E,CPMS.ABDULLAH_SALARIES S,CPMS.ABDULLAH_CONTRIBUTIONS C
where M.MERGE_ID=E.MERGE_ID
and E.EMPLOYMENT_ID=S.EMPLOYMENT_ID
and S.SALARY_ID=C.SALARY_ID
group by M.EMPLOYEE_NUMBER)t1
inner join
(select EMPNO,count(EMPNO)as numfacon,sum(PENSND)
from CON1.PEN_DED
where PENSND !=0
group by EMPNO)t2
on t1.EMPLOYEE_NUMBER = t2.EMPNO

1 个答案:

答案 0 :(得分:1)

我认为尽管使用*,您应该在选择任何列后选择您的列,它将显示在结果中。

select t1.EMPLOYEE_NUMBER,
empnumcon
from
(select M.EMPLOYEE_NUMBER,count(M.EMPLOYEE_NUMBER)as empnumcon,sum(C.MEMBER_PAID_AMOUNT)
  from CPMS.ABDULLAH_MEMBERS M,CPMS.ABDULLAH_EMPLOYMENTS E,CPMS.ABDULLAH_SALARIES S,CPMS.ABDULLAH_CONTRIBUTIONS C
          where M.MERGE_ID=E.MERGE_ID
          and E.EMPLOYMENT_ID=S.EMPLOYMENT_ID
         and S.SALARY_ID=C.SALARY_ID
         group by M.EMPLOYEE_NUMBER)t1
          inner join
          (select EMPNO,count(EMPNO)as numfacon,sum(PENSND)
           from CON1.PEN_DED
          where PENSND !=0
          group by EMPNO)t2
         on t1.EMPLOYEE_NUMBER = t2.EMPNO

[请参阅此链接] [1]

http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx