create or replace view "AuswertungIOTNSEG" as
				 select "Leistungsart","IOTNQS", count("IOTNQS") as "Anzahl", '3'::varchar as "G"
				 from "QsEintrag" qse
				  where qse."StornoDatum" is null
							  group by "Leistungsart","IOTNQS"
							  UNION
							  select 'Alle' as "Leistungsart", 'NichtStornierte' as "IOTNQS", count(*) as "Anzahl", '0'::varchar as "G"
							  from "QsEintrag" qse
							  where qse."StornoDatum" is null
							  UNION
							  select 'Alle' as "Leistungsart", 'Stornierte' as "IOTNQS", count(*) as "Anzahl", '1'::varchar as "G"
							  from "QsEintrag" qse
							  where qse."StornoDatum" is not null
							  UNION 
							  select 'Alle' as "Leistungsart", 'Alle' as IOTNQS, count(*) as "Anzahl", '2'::varchar as "G"
							  from "QsEintrag" qse
							  order by "G","Leistungsart" asc ,"Anzahl" desc, "IOTNQS" desc