Oracle SQL aliases

Source: Internet
Author: User
Tags aliases cdata

An alias for the SQL field, often thought to be optional, but sometimes necessary.

For example, in Ibatis

1 <!--get a list of sent or pending MMS Records--2     <Resultmap ID="Mmslistbyrecordtypemap" class="Richinfo.mms.bean.req.MmsRecordReq">3         <Resultcolumn="GroupID" Property="GroupId"/>4         <Resultcolumn="Subject" Property="Title"/>5         <Resultcolumn="Sendnumber" Property="Usernumber"/>6         <Resultcolumn="Destnumbers" Property="Destnumber"/>7         <Resultcolumn="Istime" Property="Istimming" Typehandler="Richinfo.mms.util.MyBatisTypeHandlerCallback"/>8         <Resultcolumn="Statuss" Property="Status"/>9         <Resultcolumn="Startsendtime" Property="Sendtime"/>Ten         <Resultcolumn="TotalSize" Property="TotalSize"/> One     </Resultmap> A     <SelectId="Getmmslistbyrecordtype" Resultmap="Mmslistbyrecordtypemap" -ResultClass="Map"> -         Select *  from(SelectB.*, RowNum R from(Select  theUin,fn_getdecryptusernumber (Sendnumber) Sendnumber,subject,to_char (Startsendtime,'YYYY-MM-DD Hh24:mi:ss')  - Startsendtime,istime,showfileid,totalsize,showtype,groupid, - Wmsys.wm_concat (Fn_getdecryptusernumber (Destnumber)) Destnumbers,wmsys.wm_concat (NVL (Status, -         0)) Statuss fromMms_send_his_recordwhere 1=1  +         <IsEqual prepend=" andThe property="RecordType" CompareValue="0"> -Issave=1  +         </IsEqual> A         <IsEqual prepend=" andThe property="RecordType" CompareValue="1"> at         <![cdata[ - (istime=0 or (istime=1 and startsendtime<=sysdate)) and issave=1 -         ]]> -         </IsEqual> -         <IsEqual prepend=" andThe property="RecordType" CompareValue="2"> -         <![cdata[ in istime=1 and Startsendtime>sysdate -             ]]> to         </IsEqual> +          andUIn=#uin # -         <Include refID="Condition"/> the         <![cdata[ * GROUP by Groupid,uin,fn_getdecryptusernumber (Sendnumber), subject,startsendtime,istime,showfileid,totalsize,s Howtype ORDER BY startsendtime Desc) b $ where RowNum <= #endRecord #Panax Notoginseng          ]]> -         <Isnotempty Property="Destnumber"> the         <![cdata[ + and InStr (Destnumbers, #destNumber #) >0 or InStr (Destnumbers,fn_encrypt_function (#destNumber #)) >0 A             ]]> the         </Isnotempty> +)whereR>#startRecord # -     </Select>

1, must be the 15th, 17 line Alias

If you do not alias lines 15th and 17, the execution of the SQL statement will be problematic. Because the query result set for this select is mapped on the Mmslistbyrecordtypemap, this time

If you do not alias, Fn_getdecryptusernumber (Sendnumber) and sendnumber are not equal, and the result cannot be mapped on usernumber.

Therefore, the names of the column names and Resultmap of the select query must be equal.

2. The GROUP BY statement does not require an alias

Oracle SQL aliases

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.