An SQL statement used to filter duplicate data

Source: Internet
Author: User

The data is as follows:

303 standard category TR_STANDARD_MANAGER
107 inspection record category TR_PATROL_LOG
61 inspection record category TR_PATROL_LOG
221 TR_REPAIR_LOG
121 Maintenance Management Plan category TR_REPAIR_PLAN
141 Maintenance Management Plan category TR_REPAIR_PLAN
24 device management category TR_PATROL_PLAN_1
105 inspection plan Category TR_PATROL_PLAN
108 Maintenance Management Plan category TR_REPAIR_PLAN
109 TR_REPAIR_LOG
1 inspection plan Category TR_PATROL_PLAN
2 inspection record category TR_PATROL_LOG
26 equipment management category TR_PATROL_PLAN_1
142 TR_REPAIR_LOG
145 accident type TR_ACCIDENT
144 accident type TR_ACCIDENT
261 inspection plan Category TR_PATROL_PLAN
147 load type TR_BURTHEN
262 inspection plan Category TR_PATROL_PLAN
265 inspection plan Category TR_PATROL_PLAN
267 Maintenance Management Plan category TR_REPAIR_PLAN
268 Maintenance Management Plan category TR_REPAIR_PLAN
269 accident type TR_ACCIDENT
146 accident type TR_ACCIDENT
283 standard category TR_STANDARD_MANAGER
263 inspection plan Category TR_PATROL_PLAN
5 Data Category TR_EQUP_ATT_INFO
266 Maintenance Management Plan category TR_REPAIR_PLAN
281 data category TR_EQUP_ATT_INFO

//////////////////////////////////////// //

You need to obtain a non-repeated category name and the corresponding primary key id.

Select scop_name, RUN_TYPE_ID from tr_type a where
RUN_TYPE_ID = (select max (RUN_TYPE_ID) FROM tr_type B where a. scop_name = B. scop_name)

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.