我上一场比赛,我在那里有一个表称为punishment
工作的组合获得最高日已下面的架构与日,月和年
CREATE TABLE Punishment
(
PunishmentId int identity(1,1) not null ,
PunishmentDay int ,
PunishmentMonth int ,
PunishmentYear int ,
GameId int
)
PunishmentDay,PunishmentMonth,PunishmentYear是数字可以是零或空或任何数字。
GameId
可以在此表中重复,意味着我可以在同一场比赛中获得多次惩罚。
现在我的问题是我必须得到punishmentId
其中用户得到最高的处罚。
我曾尝试以下方法,但没能获得最大记录..
SELECT PunishmentId, DATEADD(DD,PunishmentDay,DATEADD(MM,PunishmentMonth,(DATEADD(YY,PunishmentYear,GETDATE()))))
FROM Punishment
因为处罚不是日期。这些都是数字....可能是你得到3天的惩罚,我会得到2年的惩罚..和惩罚开始日期也定义在游戏的后期阶段。 – rahularyansharma
然后,最大组合将是'MAX(年* 10000 +月* 100 +日)' –
为什么不将规则化所有处罚时间在几天?您可以使用30天的月份和365天的年份,而不会显着不准确。 –