Use a view with one row, and an outer one to another table / query.
Here is an example with a table variable @T instead of your real table.
declare @T table ( ID int, Grp int ) select isnull(Q.MaxID, 0) as MaxID, isnull(QC, 0) as C from (select 1) as T(X) outer apply (
This will result in the output always having at least one line.
Something like this using your request.
select isnull(Q.TipoVers, '0') as TipoVers, isnull(Q.ImpTot, 0) as ImpTot, isnull(QN, 0) as N, isnull(Q.Mese, 0) as Mese from (select 1) as T(X) outer apply ( SELECT TV.Descrizione as TipoVers, sum(ImportoVersamento) as ImpTot, count(*) as N, month(DataAllibramento) as Mese, V.IDTipoVersamento FROM PROC_Versamento V left outer join dbo.PROC_TipoVersamento TV on V.IDTipoVersamento = TV.IDTipoVersamento inner join dbo.PROC_PraticaRiscossione PR on V.IDPraticaRiscossioneAssociata = PR.IDPratica inner join dbo.DA_Avviso A on PR.IDDatiAvviso = A.IDAvviso where DataAllibramento between '2012-09-08' and '2012-09-17' and A.IDFornitura = 4 group by V.IDTipoVersamento,month(DataAllibramento),TV.Descrizione ) as Q order by Q.IDTipoVersamento, Q.Mese
source share