vendredi 2 octobre 2020

Hide 50% of rows with low value with MySQL

I have a table with three columns:

  • Description (string)
  • Value (integer from 1-3)
  • Date

I want to build a select which returns:

  • 100% of rows with value 3
  • 50% of rows with value 2
  • 25% of rows with value 1

Ordered by date. „Hiding“ rows with value 1 or 2 could be random but doesn’t have to (e.g. „hide“ every second row with value 2)

It this possible with one query and without additional PHP scripts?




Aucun commentaire:

Enregistrer un commentaire