我遇到一些麻烦,看到语句下面的语法错误。我尝试在fiddle demo 上运行它并且它有效。我正在使用Sql Server 2005,兼容模式是90。
SELECT
C.col,C.value,C.sortorder
FROM
PAY_REGISTRY PR
CROSS APPLY
(
VALUES (9,'Basic Salary',SALARY),
(10,'SANS Withholding',SANS),
(11,'Probationary Withholding',PROBI),
(12,'After PP Deduction',A_PP),
(13,'DAF Deduction',DAF),
(14,'Annual Leave',LIV_A),
(15,'Sick Leave',LIV_S),
(16,'Rest and Recreation',LIV_R),
(17,'Maternity Leave',LIV_M),
(18,'Paternity Leave',LIV_P),
(19,'Unpaid Leave',LIV_U),
(20,'Meal Allowance',MEAL),
(21,'Transportation Allowance',TRANS),
(22,'Business and Travel Allowance',TRAVEL),
(23,'Site Allowance',[SITE]),
(24,'Mobile / Phone Allowance',PHONE),
(25,'Education Allowance',EDU),
(26,'Bonus',BONUS),
(27,'Adjustment',ADJ),
(28,'AL Pay',AL_P),
(29,'Gross Pay',GROSS),
(30,'Retention Gross Pay',L_PP),
(31,'SHI Employee',SHI_EE),
(32,'SHI Employer',SHI_ER),
(33,'PIT',PIT),
(34,'Net Pay',NPAY),
(35,'Adjustment (Advance)',ADJ_AP),
(36,'Total Advance Salary',FS_AP),
(37,'Adjustment (Final)',ADJ_FP),
(38,'Total Final Salary',FS_FP)
) C (sortorder,col,value)
答案 0 :(得分:3)
The table values constructor。您可以使用带(select ... union all select ...)
的派生表。