考虑一个表:
// Ensure mandatory file attributes have been located. Need either destination, or site + container or updateNodeRef
if ((filename === null || content === null) || (destination === null && (siteId === null || containerId === null) && updateNodeRef === null))
{
exitUpload(400, "Required parameters are missing");
return;
}
状态更新日期是人员状态更改的日期有效期到期时有效到期,有效时有效
我想获取所有有效许可证和许可证在过去30天内过期的记录,其他过期许可证将被忽略
假设当前日期为╔══════╦════════════╦═════════╦════════════════════╦═════════╗
║ Name ║ License No ║ Status ║ Status_update_date ║ Address ║
╠══════╬════════════╬═════════╬════════════════════╬═════════╣
║ Jon ║ 1234 ║ Active ║ 01/01/2016 ║ aaaa ║
║ Rick ║ 5678 ║ Expired ║ 31/11/2015 ║ xxxx ║
║ Bob ║ 0987 ║ Expired ║ 30/01/2016 ║ ssss ║
║ Carl ║ 3456 ║ Active ║ 03/12/2015 ║ qqqq ║
╚══════╩════════════╩═════════╩════════════════════╩═════════╝
:
05/02/2016
一个限制是查询不应包含╔══════╦════════════╦═════════╦════════════════════╦═════════╗
║ Name ║ License No ║ Status ║ Status_update_date ║ Address ║
╠══════╬════════════╬═════════╬════════════════════╬═════════╣
║ Jon ║ 1234 ║ Active ║ 01/01/2016 ║ aaaa ║
║ Bob ║ 0987 ║ Expired ║ 30/01/2016 ║ ssss ║
║ Carl ║ 3456 ║ Active ║ 03/12/2015 ║ qqqq ║
╚══════╩════════════╩═════════╩════════════════════╩═════════╝
。
答案 0 :(得分:1)
状态和 Status_update_date 需要scala-2.11.17
条件,因为它们无法同时发生。
OR
要获取当前日期,您可以使用SELECT *
FROM table_name
WHERE status = 'Active'
OR ( status = 'Expired'
AND Status_update_date >= SYSDATE -30
);
或SYSDATE
,前提是时区对于会话和数据库服务器的操作系统。< / p>
答案 1 :(得分:0)
你可以试试这个:
SELECT *
FROM myatble
WHERE Stauts = 'Active' OR Expiration_DT > sysdate-30
答案 2 :(得分:0)
SELECT * FROM YOUR_TABLE WHERE STATUS='ACTIVE' AND EXPIRATION_DATE > SYSDATE - INTERVAL '30' DAY