我創建4個輸入參數(2 * ID,年份和月份),即在WHERE
子句中使用存儲過程查找記錄。
問題是我只是不能編寫正確的語法來獲取在某個特定月份的價值(Koeficient)。
ALTER PROCEDURE [dbo].[obrPla_DohvatiPojedineRadniciKoeficientZaObracun]
(
@IDFirma INT,
@IDRadnik INT,
@Godina SMALLINT,
@Mjesec TINYINT
)
AS BEGIN
SELECT rk.Koeficient
FROM RadniciKoeficient rk
WHERE rk.IDFirma = @IDFirma
AND rk.IDRadnik = @IDRadnik
AND DATEPART(yyyy, rk.DatumOd) = @Godina
AND CASE WHEN rk.DatumDo IS NOT NULL
THEN DATEPART(mm, rk.DatumOd) <= @Mjesec AND @Mjesec <= DATEPART(mm, rk.DatumDo)
ELSE DATEPART(mm, rk.DatumOd) <= @Mjesec
END
END
除非你清楚地表達事情,否則你不能指望別人幫助你,對嗎? – MusicLovingIndianGirl
你有什麼疑問? – massie
你能舉一個例子:輸出應該是什麼 –