select id,HEAD_ID as headId,BUSINESS_ID as businessId,CHECK_STATUS as checkStatus ,VESSEL_NAME_EN as vesselNameEn ,IMO_NO as imoNo ,VOYAGE as voyage ,PRE_INPUT_NO as preInputNo,MANAGE_COMPANY as manageCompany ,SEND_TIME as sendTime ,INOUT_SIGN as inOutSign ,IN_STORAGE_NO as inStorageNo ,SEND_UNIT as sendUnit ,RECEIVE_UNIT as receiveUnit ,IN_STORAGE_TIME as inStorageTime,CUS_NAME as cusName, CUS_CODE as cusCode, MATERIEL_TYPE_NAME as materielTypeCode from T_RANDOM_CHECK_BODY_INFO where HEAD_ID='820' 将查询结果 根据materielTypeCode等于 免税烟及制品 的在前从上到下排列
时间: 2023-11-22 20:04:13 浏览: 136
以下是根据materielTypeCode等于免税烟及制品的在前从上到下排列的SQL查询语句:
```
SELECT id, HEAD_ID AS headId, BUSINESS_ID AS businessId, CHECK_STATUS AS checkStatus, VESSEL_NAME_EN AS vesselNameEn, IMO_NO AS imoNo, VOYAGE AS voyage, PRE_INPUT_NO AS preInputNo, MANAGE_COMPANY AS manageCompany, SEND_TIME AS sendTime, INOUT_SIGN AS inOutSign, IN_STORAGE_NO AS inStorageNo, SEND_UNIT AS sendUnit, RECEIVE_UNIT AS receiveUnit, IN_STORAGE_TIME AS inStorageTime, CUS_NAME AS cusName, CUS_CODE AS cusCode, MATERIEL_TYPE_NAME AS materielTypeCode
FROM T_RANDOM_CHECK_BODY_INFO
WHERE HEAD_ID = '820'
ORDER BY CASE WHEN MATERIEL_TYPE_NAME = '免税烟及制品' THEN 0 ELSE 1 END, id ASC;
```
这条SQL语句会首先按照MATERIEL_TYPE_NAME是否为免税烟及制品进行排序,是的话排在前面(0),不是的话排在后面(1),然后再按照id进行升序排序。
阅读全文