Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    MYSQL Query con LEAST ma senza considerare < 0

    Salve a tutti,
    ho la necessità di effettuare una query simile a:

    SELECT LEAST(0,2,10,3,4)

    Ma il risultato deve essere maggiore a 0.

    Come potrei fare?

    Grazie!

  2. #2
    Utente di HTML.it L'avatar di nicola75ss
    Registrato dal
    Nov 2004
    Messaggi
    12,922
    codice:
    select id,substring_index(group_concat(campo order by campo),',',1) as minore from (
    select id,campo1 as campo from tabella where campo1 > 0
    union all
    select id,campo2 from tabella where campo2 > 0
    union all
    select id,campo3 from tabella where campo3 > 0
    union all
    select id,campo4 from tabella where campo4 > 0
    union all
    select id,campo5 from tabella where campo5 > 0
    ) as t
    group by id

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.