Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
initial_wm
Starting Member
3 Posts |
Posted - 2008-12-11 : 01:08:31
|
Hello, I Have an Query Like :DECLARE @MonthProcess VARCHAR(20);DECLARE @Foreign Varchar(20);SET @MonthProcess = '200811'SET @Foreign = 'True'SELECT TR_Crew_Salary_History.Crew_ID, M_Rank.[Rank], TR_Crew_Data.Name, M_Vessel.Vessel_Name, TR_Crew_Salary_History.Fixed, TR_Crew_Salary_History.FOT, TR_Crew_Salary_History.Vessel_Allowance, TR_Crew_Salary_History.Seniority_Allowance, TR_Crew_Salary_History.Special_Allowance, (CASE (TR_Crew_Salary_History.Currency_ID) WHEN 'USD' THEN TR_Crew_Salary_History.Loan / (SELECT Rate FROM M_Exchange_Rate WHERE Year_Month = @MonthProcess) ELSE TR_Crew_Salary_History.Loan END) AS Loan, (CASE (TR_Crew_Salary_History.Currency_ID) WHEN 'USD' THEN TR_Crew_Salary_History.HA_Amount / (SELECT Rate FROM M_Exchange_Rate WHERE Year_Month = @MonthProcess) ELSE TR_Crew_Salary_History.HA_Amount END) AS HA_Amount,M_Country.[Foreign]FROM TR_Crew_Salary_History INNER JOIN M_Rank ON TR_Crew_Salary_History.Rank_ID = M_Rank.Rank_ID INNER JOIN TR_Crew_Data ON TR_Crew_Salary_History.Crew_ID = TR_Crew_Data.Crew_ID INNER JOIN M_Vessel ON TR_Crew_Salary_History.Vessel_ID = M_Vessel.Vessel_ID INNER JOINM_Country ON TR_Crew_Data.Nationality = Country_ID WHERE TR_Crew_Salary_History.Month_Process = @MonthProcessAND M_Country.[Foreign] = @ForeignORDER BY M_Vessel.Vessel_Name, TR_Crew_Data.Crew_IdIn This Case, I Use Case... When... Then... End For The Conditional,and now I am trying to use IF Conditional, but I get error in IF conditional...any body can help me ? regards |
|
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2008-12-11 : 01:30:23
|
First y do u want IF? it looks fine with CASE.Is there any business rules need to be included?"There is only one difference between a dream and an aim.A dream requires soundless sleep to see,whereas an aim requires sleepless efforts to achieve..!!" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-11 : 02:03:08
|
| As per posted code, i cant see any reason why you want use if here. |
 |
|
|
initial_wm
Starting Member
3 Posts |
Posted - 2008-12-11 : 06:02:42
|
| that's true, there's no problem in my posted code...,but i just want to try IF Conditional in this case (my posted code),cause I think CASE Conditional More Complicated than IF Conditional if there's case that need more than 1 condition..., regards |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-11 : 09:49:13
|
quote: Originally posted by initial_wm that's true, there's no problem in my posted code...,but i just want to try IF Conditional in this case (my posted code),cause I think CASE Conditional More Complicated than IF Conditional if there's case that need more than 1 condition..., regards
they are used for two different purposes. Case expression is use to conditionally select value for a field while if is used to conditionally vary resultsets. |
 |
|
|
initial_wm
Starting Member
3 Posts |
Posted - 2008-12-11 : 23:23:34
|
| thanks for the answer, it solved my problem...thanks for all |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-12 : 09:36:51
|
| welcome |
 |
|
|
|
|
|
|
|