ALTER PROCEDURE [dbo].[K_FS_GetFEEDMRPDetails]
AS
BEGIN
SET NOCOUNT ON;
Select
FT.FeedType,
round(MR.rateperkg, 3) as rateperkg,
round(MR.rateper50kg, 3)as rateper50kg
from
K_FS_FeedMrpDetails MR
inner join
k_FPS_FeedType FT on FT.sno = MR.feedtype
where
date = convert(varchar(10), getdate(), 101)
END
此查询显示今天的插入数据。这是正确的,但我也想,如果今天没有输入任何数据,那么我想显示最后输入的数据。我怎样才能做到这一点?请帮帮我......
答案 0 :(得分:1)
此代码将选择最新插入的行
SELECT FT.FeedType,
Round( MR.rateperkg,3)As rateperkg,
Round( MR.rateper50kg,3)As rateper50kg
FROM K_FS_FeedMrpDetails MR
inner join k_FPS_FeedType FT
On FT.sno=MR.feedtype
WHERE date in (SELECT TOP 1 date FROM K_FS_FeedMrpDetails ORDER BY date Desc )