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 |
|
coagulance
Yak Posting Veteran
78 Posts |
Posted - 2008-04-28 : 15:05:44
|
| Would like to know if it is possiblefor any of you to suggest how to conditionally diaplay a Column based on the values of the other columns.Here's my querySELECT [ProductionDay] ,DATEPART(wk,StartTime) AS WeekCount ,(AVG([RNTDuration])) AS AvgRNT ,MIN([RNTDuration]) As LeastRNT ,MAX([RNTDuration]) As WorstRNT ,dbo.fn_MinimumRNT_sp([ProgramNo],[Machine],[ProductionDay]) AS BestRNT ,dbo.fn_MinimumRNT(SubAssemblyNo,[Machine]) AS BestRNT_txt ,SUM([LoadingDuration]) AS LoadingTime ,[ProgramNo] AS ProgramNo ,COUNT(RNTID) AS PartsCount ,[SubAssemblyNo] ,[Sheetsize] FROM [RPMS].[dbo].[List_MachineShopRNT] where Machine = @iMachine and dateadd(month, datediff(month, 0, [StartTime]),0) = @dtMonthStartDateGroup by DATEPART(wk,StartTime), [ProductionDay],[Machine],[ProgramNo],[SubAssemblyNo],[Sheetsize]Here I would like to Run the function dbo.fn_MinimumRNT_sp or dbo.fn_MinimumRNT if the ProgramNo is 100Thank you |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-28 : 15:15:49
|
| use CASE WHEN constructCASE WHEN [ProgramNo]=100 THEN dbo.fn_MinimumRNT_sp([ProgramNo],[Machine],[ProductionDay]) ELSE <else condition value> END |
 |
|
|
coagulance
Yak Posting Veteran
78 Posts |
Posted - 2008-04-28 : 15:19:26
|
| Thanks ,I was missing some syntax in CASE statement and hence got puzzled!! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-28 : 15:21:19
|
quote: Originally posted by coagulance Thanks ,I was missing some syntax in CASE statement and hence got puzzled!!
You're welcome |
 |
|
|
|
|
|
|
|