The use of SQL stuff stitching strings

Source: Internet
Author: User

To display Figure 2 as a method of Figure 1: The stuff function is used, and the time shown in Figure 1 is truncated.

Figure 2sql, just plain SQL

Select  from where Sfzh='152923199608242120' and CONVERT (varchar)=' 20161015 ' ORDER by SKSJ

Figure 1sql, using the stuff stitching

SelectDz. Xm asName, DZ. Jszh asCard number, [Swipe Time]=stuff (Select ','+substring (CONVERT (varchar ( -), SKSJ,8),0,6)  fromAccess_statisticswhereSfzh=MJ. Sfzh and CONVERT (varchar ( -), SKSJ, the)='20161015'and sfzh='152923199608242120'ORDER BY SKSJ forXML Path ("') ),1,1,"')   fromaccess_statistics Mjinner join Readers dz on DZ. Sfzh=MJ. Sfzhinner join XX04 BJ on DZ. BJBH=BJ. BJBHwhereCONVERT (varchar ( -), MJ. SKSJ, the)='20161015'and MJ. Sfzh='152923199608242120'GROUP BY MJ. Sfzh,dz. Xm,dz. Jszh

The use of SQL stuff stitching strings

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.