we have a DB which stores users who may have pictures.
I am looking for an elegant way in SQL to get the following results:
Select n users. Of those n users e.g. 60% should have an associated picture and 40% should not have a picture. If there are less than 60% users having a picture the result should be filled up with users wihtout an image.
Is there some elegant way in SQL without firing multiple SELECTs to the DB?
Thank you very much.
Ugly code: