De-duplication that cannot be solved by distinct in sqlserver maxgroupby_MySQL

Source: Internet
Author: User
De-duplication that cannot be solved by distinct in sqlserver maxgroupby bitsCN.com

De-duplication cannot be solved by distinct in sqlserver max groupby

1: SELECT * FROM T_STANDARD_SYSTEM group by SYSTEM_ID order by SYSTEM_ID2: SELECT *, COUNT (DISTINCT system_id) FROM T_STANDARD_SYSTEM group by SYSTEM_ID order by SYSTEM_IDselect * FROM T_STANDARD_SYSTEM WHERE system_Id IN (select max (system_id) FROM T_STANDARD_SYSTEM group by system_id)

The second article above solves the incompatibility problem between different mysql versions. The first article can be used in some versions. But neither of them can be used in sqlserver.

SELECT SYSTEM_ID, MAX (SYSTEM_NAME) SYSTEM_NAME, MAX (SYSTEM_ABRIDGE) SYSTEM_ABRIDGE, MAX (SUB_SYSTEM_ID) SUB_SYSTEM_ID, MAX (SUB_SYSTEM_NAME) SUB_SYSTEM_NAME, MAX (CUSTOM_SYSTEM_ID) CUSTOM_SYSTEM_ID, MAX (CUSTOM_SYSTEM_NAME) CUSTOM_SYSTEM_NAME FROM T_STANDARD_SYSTEM group by SYSTEM_ID order by SYSTEM_ID

The above article solves the incompatibility problem between sqlserver and mysql.

Oracle provides a rowId to easily solve the preceding deduplication problem through subqueries.


BitsCN.com

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.