Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:09:09+00:00 2026-06-16T17:09:09+00:00

I want to delete some random data from my table, and cut 90% rows

  • 0

I want to delete some random data from my table, and cut 90% rows (I have very large data, I just need a sample), table looks like this:

ID    |Trans_No    |Doctor_ID |Trans_Type                    |PM |Cost
12340 |10.853329   |          |ADMINISTRASI                  |   |0.00
12341 |10.853329   |1004      |JASA MEDIS                    |   |25000.00
12342 |10.853329   |          |OBAT RESEP FARMASI NO : 177   |F  |2000.00
12343 |10.836033   |          |ADMINISTRASI                  |   |0.00
12344 |10.836033   |1001      |JASA MEDIS                    |   |25000.00
12345 |10.836033   |          |OBAT RESEP FARMASI NO : 317   |F  |0.00
12346 |10.836032   |          |ADMINISTRASI                  |   |0.00
12347 |10.836032   |1004      |JASA MEDIS                    |   |25000.00
12348 |10.836032   |          |PEMERIKSAAN RADIOLOGI NO 092.1|R  |15000.00
12349 |10.836034   |1064      |JASA MEDIS                    |   |25000.00
12350 |10.836034   |          |PEMERIKSAAN RADIOLOGI NO 093.1|R  |20000.00

I think this query will work:

DELETE FROM my_table WHERE RAND() <= 0.9

but as you can see, some data has same trans_no, if one trans_no is deleted, the other data that has same trans_no should be deleted to, is there any query to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:09:11+00:00Added an answer on June 16, 2026 at 5:09 pm

    You should select eligible trans_no first and then delete them, like this:

    DELETE FROM my_table
    WHERE trans_no IN (
        SELECT trans_no
        FROM (SELECT DISTINCT trans_no FROM my_table) x
        WHERE rand() <= 0.9
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to delete some data displayed in a HTML table row (first on
I have a table with about 100k records and I want to delete some
I have some strings that I want to delete some unwanted characters from them.
I want to delete some data from database: WHERE created_at < NOW() - 30
I have a table view that I want to delete some of the cells
i want to delete some unwanted text from the following data with xslt Address>
I want to delete some rows from DataTable, but it gives an error like
i have table called users , if i want to delete some user (User
I am trying to delete some data from one table using multiple table. The
I want to delete DataRows from a DataTable. The rows to be deleted are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.