| Author |
Topic |
|
khufiamalik
Posting Yak Master
120 Posts |
Posted - 2008-08-19 : 06:13:19
|
| Hello All,select Basic_Pay*60/100 from (select Emp_Code,Basic_Pay,[Start_Date],End_Date,Fiscal_Year_ID from EMP_Salaryunionselect Emp_Code,Basic_Pay,[Start_Date],End_Date,Fiscal_Year_ID from EMP_Salary_History) as Table2where Emp_Code='Sys_EMP1' and Fiscal_Year_ID=1 and [Start_Date]=(select MAX([Start_Date]) from Table2) I want to check the maximum date selected by Union Query.Can any one help me?Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-19 : 06:16:29
|
[code];WITH Table2 (Emp_Code, Basic_Pay, Start_Date, End_Date, Fiscal_Year_ID)( SELECT Emp_Code,Basic_Pay,[Start_Date],End_Date,Fiscal_Year_ID FROM EMP_Salary UNION SELECT Emp_Code,Basic_Pay,[Start_Date],End_Date,Fiscal_Year_ID FROM EMP_Salary_History) AS Table2SELECT Basic_Pay*60/100 FROM Table2WHERE Emp_Code='Sys_EMP1' AND Fiscal_Year_ID=1AND [Start_Date]=(SELECT MAX([Start_Date]) FROM Table2) [/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-19 : 06:17:36
|
Use a CTE :-;With CTE(Emp_Code,Basic_Pay,[Start_Date],End_Date,Fiscal_Year_ID)AS(select Emp_Code,Basic_Pay,[Start_Date],End_Date,Fiscal_Year_ID from EMP_Salaryunionselect Emp_Code,Basic_Pay,[Start_Date],End_Date,Fiscal_Year_ID from EMP_Salary_History)select Basic_Pay*60/100 from CTEwhere Emp_Code='Sys_EMP1' and Fiscal_Year_ID=1 and [Start_Date]=(select MAX([Start_Date]) from CTE) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-19 : 06:18:27
|
ah...beaten again |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-19 : 06:24:04
|
It rarely happened  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
khufiamalik
Posting Yak Master
120 Posts |
Posted - 2008-08-19 : 06:24:13
|
| Thanks Alot, you people solved my problem |
 |
|
|
khufiamalik
Posting Yak Master
120 Posts |
Posted - 2008-08-19 : 06:24:14
|
| Thanks Alot, you people solved my problem |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-19 : 06:30:11
|
quote: Originally posted by khufiamalik Thanks Alot, you people solved my problem
was that posted twice to address each of us? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-19 : 06:52:08
|
should use DISTINCTselect distinct thanks from table KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|