select VERSION from ZFS_Sys.SYS BOE TYPE where boe type code= 'NEW FUND COLLECTION' 我想取这个表里面 type_code 获取version最大的那一条
时间: 2024-05-07 14:20:42 浏览: 92
你可以使用以下 SQL 查询语句来获取 `NEW FUND COLLECTION` 类型的 `VERSION` 最大的记录:
```
SELECT MAX(VERSION)
FROM ZFS_Sys.SYS_BOE_TYPE
WHERE BOE_TYPE_CODE = 'NEW FUND COLLECTION'
```
如果你想获取该记录的其他字段,可以使用以下 SQL 查询语句:
```
SELECT *
FROM ZFS_Sys.SYS_BOE_TYPE
WHERE BOE_TYPE_CODE = 'NEW FUND COLLECTION'
AND VERSION = (SELECT MAX(VERSION) FROM ZFS_Sys.SYS_BOE_TYPE WHERE BOE_TYPE_CODE = 'NEW FUND COLLECTION')
```
这个 SQL 查询语句会返回 `BOE_TYPE_CODE` 等于 `NEW FUND COLLECTION` 且 `VERSION` 最大的记录的所有字段。
相关问题
SELECT COUNT(1) FROM ZFS_OP.OP_EFS_PAYMENT WHERE GROUP_ID='35f1594c-6139-4b8e-9d19-a6d42d579e0c' AND PAYMENT_STATUS=30 AND ARCHIVE_DATE AND ENABLED_FLAG=0 AND VALIDITY_FLAG=0 AND ON_OFF_LINE=0b补充sql,写三个sql,ARCHIVE_DATE条件是本年,本月,本日
补充 SQL:
1. 本年:
```
SELECT COUNT(1) FROM ZFS_OP.OP_EFS_PAYMENT
WHERE GROUP_ID='35f1594c-6139-4b8e-9d19-a6d42d579e0c'
AND PAYMENT_STATUS=30
AND ARCHIVE_DATE >= DATE_FORMAT(NOW(),'%Y-01-01')
AND ARCHIVE_DATE <= DATE_FORMAT(NOW(),'%Y-12-31')
AND ENABLED_FLAG=0
AND VALIDITY_FLAG=0
AND ON_OFF_LINE=0;
```
2. 本月:
```
SELECT COUNT(1) FROM ZFS_OP.OP_EFS_PAYMENT
WHERE GROUP_ID='35f1594c-6139-4b8e-9d19-a6d42d579e0c'
AND PAYMENT_STATUS=30
AND ARCHIVE_DATE >= DATE_FORMAT(NOW(),'%Y-%m-01')
AND ARCHIVE_DATE <= LAST_DAY(NOW())
AND ENABLED_FLAG=0
AND VALIDITY_FLAG=0
AND ON_OFF_LINE=0;
```
3. 本日:
```
SELECT COUNT(1) FROM ZFS_OP.OP_EFS_PAYMENT
WHERE GROUP_ID='35f1594c-6139-4b8e-9d19-a6d42d579e0c'
AND PAYMENT_STATUS=30
AND ARCHIVE_DATE >= DATE_FORMAT(NOW(),'%Y-%m-%d')
AND ARCHIVE_DATE <= DATE_FORMAT(NOW(),'%Y-%m-%d')
AND ENABLED_FLAG=0
AND VALIDITY_FLAG=0
AND ON_OFF_LINE=0;
```
注意:以上 SQL 仅供参考,具体需要根据实际情况进行调整。
CREATE VIEW OP_EFS_PAYMENT_V AS SELECT PAYMENT_NO, LE_NAME, PAYMENT_ACCOUNT_ID, GATHER_BANK_ACCOUNT_NAME, GATHER_BANK_BRANCH_NAME, GATHER_BANK_ACCOUNT_NUM, PAYMENT_AMOUNT, PAYMENT_MEMO, BOE_NO, FORM_TYPE_NAME, EMPLOY_NAME, PUB_PRI_CODE, CURRENCY_CODE, PAYMENT_MODE_NAME, POSTAL_ORDER_CODES, PAYMENT_DATE, PAYMENT_STATUS, ERROR_MSG, AUDIT_DATE FROM ZFS_OP.OP_EFS_PAYMENT;为视图中的字段添加注释付款单号 PAYMENT_NO 核算主体名称 LE_NAME 付款银行账号 PAYMENT_ACCOUNT_ID 收款人 GATHER_BANK_ACCOUNT_NAME 收款银行支行名称 GATHER_BANK_BRANCH_NAME 收款银行账号 GATHER_BANK_ACCOUNT_NUM 付款金额 PAYMENT_AMOUNT 付款用途 PAYMENT_MEMO 单据编号 BOE_NO 单据类型名称 FORM_TYPE_NAME 报账人名称 EMPLOY_NAME 对公对私 PUB_PRI_CODE 付款币种 CURRENCY_CODE 支付方式名称 PAYMENT_MODE_NAME 汇票票据号 POSTAL_ORDER_CODES 付款时间 PAYMENT_DATE 付款状态 PAYMENT_STATUS 付款失败原因 ERROR_MSG 出纳审核时间 AUDIT_DATE
好的,下面是添加注释的示例SQL语句:
```
COMMENT ON COLUMN OP_EFS_PAYMENT_V.PAYMENT_NO IS '付款单号';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.LE_NAME IS '核算主体名称';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.PAYMENT_ACCOUNT_ID IS '付款银行账号';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.GATHER_BANK_ACCOUNT_NAME IS '收款人';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.GATHER_BANK_BRANCH_NAME IS '收款银行支行名称';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.GATHER_BANK_ACCOUNT_NUM IS '收款银行账号';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.PAYMENT_AMOUNT IS '付款金额';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.PAYMENT_MEMO IS '付款用途';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.BOE_NO IS '单据编号';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.FORM_TYPE_NAME IS '单据类型名称';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.EMPLOY_NAME IS '报账人名称';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.PUB_PRI_CODE IS '对公对私';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.CURRENCY_CODE IS '付款币种';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.PAYMENT_MODE_NAME IS '支付方式名称';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.POSTAL_ORDER_CODES IS '汇票票据号';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.PAYMENT_DATE IS '付款时间';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.PAYMENT_STATUS IS '付款状态';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.ERROR_MSG IS '付款失败原因';
COMMENT ON COLUMN OP_EFS_PAYMENT_V.AUDIT_DATE IS '出纳审核时间';
```
在上面的SQL语句中,使用了`COMMENT ON COLUMN`语句为`OP_EFS_PAYMENT_V`视图中的每个字段添加了注释。这些注释可以通过查询`USER_COL_COMMENTS`视图来查看。
阅读全文