我有一个如下的元组,我想返回其ActivePeriod值为“ YES”的第一个元素的TimePeriodID。试图使用first和minl&ord函数,但是没有用。任何帮助将非常感激。谢谢。
tuple timeperiod {
string TimePeriodID;
string TimePeriodName;
float CurrencyRate;
float Rank;
string ActivePeriod;
}
{timeperiod} TimePeriods = ...;
答案 0 :(得分:-1)
tuple timeperiod {
string TimePeriodID;
string TimePeriodName;
float CurrencyRate;
float Rank;
string ActivePeriod;
}
{timeperiod} TimePeriods = {<"A","B",1.0,2.3,"NO">,<"V","B",4.0,2.3,"YES">,<"D","B",4.0,2.3,"YES">};
string answer=first({i | i in TimePeriods : i.ActivePeriod=="YES"}).TimePeriodID;
execute
{
writeln(answer);
}
给予
V