MySQL Forums
Forum List  »  Italian

Vista per stampa etichette
Posted by: Marcello Mela
Date: May 06, 2022 12:08PM

Ciao a tutti,

ho bisogno del Vs. aiuto per creare una vista che leggendo da una tabella che contiene un codice e una quantità (semplifico per chiarezza) con dati di questo tipo:

Codice Qta
-------- -----
CODICE1 3
CODICE2 5
CODICE3 2

mi estragga dei record con questo aspetto

Codice Qta
-------- -----
CODICE1 1
CODICE1 1
CODICE1 1
CODICE2 1
CODICE2 1
CODICE2 1
CODICE2 1
CODICE2 1
CODICE3 1
CODICE3 1

In pratica voglio ottenere un numeri di righe per ogni codice pari al numero indicato nel campo qta.

Ho trovato questa query per SQL Server, ma su MySQL non funziona. Se ho visto bene, non esiste la tabella master e non trovo una sua equivalente

Select id = row_number() over (partition by A.id order by N)
,CodiceArticolo
,Quantita = 1
From Dettagli A
Join (
Select N=Row_Number() Over (Order By (Select NULL))
From master.dbo.spt_values n1 ,master.dbo.spt_values n2
) B on N <= A.Quantita

Qualcuno sa come posso risolvere?

Grazie
Marcello

Options: ReplyQuote


Subject
Views
Written By
Posted
Vista per stampa etichette
321
May 06, 2022 12:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.