SQL Note: change the value of v_barcode in t_outbymachinedetail from the date when isdeleted is 0 to min to isdeleted 0.

Source: Internet
Author: User

 

-- Change the value of v_barcode in t_outbymachinedetail that is the same as that of min when isdeleted is 0 to isdeleted 0.
-- Powered by: Remember to forget
Update t_outbymachinedetail
Set isdeleted = 1
Where PID in (
Select PID from t_outbymachinedetail T1 right join
(
Select min (d_date) as d_mindate, v_barcode as barcode from t_outbymachinedetail where v_barcode in
(Select v_barcode from t_outbymachinedetail
Where isdeleted = 0
Group by v_barcode
Having count (*)> 1)
Group by v_barcode
) T2
On t1.d _ date = t2.d _ mindate and t1.v _ barcode = t2.barcode

Where t1.v _ barcode = t2.barcode
And t1.ischecked = 0

)

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.