Visualizzazione dei risultati da 1 a 10 su 12

Hybrid View

  1. #1
    Quote Originariamente inviata da badaze Visualizza il messaggio
    Non testato. Comunque l'idea c'è.

    Select a.store_ric, a.testo_ric, a.prezzo_ric, a.fatturato_sing, a.maxv
    from
    (select store_ric, testo_ric, prezzo_ric, fatturato_sing, max(n_venduti) as maxv)
    from tabella
    where n_venduti>100 group by store_ric) a
    inner join
    (Select store_ric, testo_ric, max(n_venduti) as maxv from tabella group by store_ric, testo_ric) b
    on a.store_ric = b.store_ric and a.testo_ric = b.testo_ric and a.maxv = b.maxv
    order by a.maxv desc limit 10
    c'era solo una parentesi di troppo:

    "Select a.store_ric, a.testo_ric, a.prezzo_ric, a.fatturato_sing, a.maxv from (select store_ric, testo_ric, prezzo_ric, fatturato_sing, max(n_venduti) as maxv from ricerche where n_venduti>80 group by store_ric) a inner join (Select store_ric, testo_ric, max(n_venduti) as maxv from ricerche group by store_ric, testo_ric) b on a.store_ric = b.store_ric and a.testo_ric = b.testo_ric and a.maxv = b.maxv order by a.maxv desc limit 20")

    e ora allinea bene i contenuti delle righe ma salta i valori piu alti..
    per intenderci mi da un risultato

    N Titolo Venduti Prezzo sing Fatturato prod Store
    1 TELECOMANDO 147 € 13.99 € 2042.54 napoli
    2 MXQ 4K 135 € 28.50 € 3847.50 napoli
    3 TESTINE 120 € 4.99 € 598.80 caserta
    4 LAMPADINE 111 € 19.99 € 2218.89 salerno

    ma nel db sono presenti anche prodotti venduti = 230, 231... come mai parte da 147...?idee??
    Ultima modifica di Stanislao; 25-02-2017 a 17:37
    L'intuizione creativa più di ogni altra cosa è l'unico elemento per cui la vita vale la pena di essere vissuta (D.W)

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.