Code:
awk -F, '
NR==1 { expect=$NF; fields=NF; last=0 }
NF != fields { last=NR;
if (NR != 2) print NR ": wrong number of fields: " $0;
if ($NF != expect) print NR ": last field value not the same as on first line"
if ($NF != NR-2) print NR ": last field not equal to line count minus two"
if ($NF != expect) print NR ": line count from first line not identical"
}
last > 0 && NR > last { print NR ": wrong number of fields: " $0 }' QDB_2008.txt