SELEZIONARE x.vSubCodeAlternative, x.vCodeAlternative, y.Counter
DA
(
SELEZIONARE vSubCodeAlternative DISTINTO, vCodeAlternative
Da dbo.tbProduct
DOVE (iProductGroupId = @iProductGroupid) E (vSubCodeAlternative <> '')
) X,
(
SELEZIONARE vCodeAlternative, il CONTEGGIO (vSubCodeAlternative distinto) come contro
Da dbo.tbProduct
DOVE (iProductGroupId = @iProductGroupid) E (vSubCodeAlternative <> '')
GRUPPO da vCodeAlternative
) Y
dove x.vCodeAlternative=Y.vCodeAlternative
ordine da x.vCodeAlternative, x.vsubCodeAlternative