your first subquery produces this –
SELECT dates, mat FROM tbl_acc
WHERE dates = '2010-10-27'
GROUP BY dates, mat
dates,mat
2010-10-27,a0
2010-10-27,a08
2010-10-27,a09
2010-10-27,a1
2010-10-27,a12
2010-10-27,a13
2010-10-27,a14
2010-10-27,a16
2010-10-27,a2
2010-10-27,a27
2010-10-27,a28
2010-10-27,a30
2010-10-27,a31
2010-10-27,a36
2010-10-27,a38
2010-10-27,a41
2010-10-27,a42
2010-10-27,a44
2010-10-27,a5
2010-10-27,a53
2010-10-27,a59
2010-10-27,a60
2010-10-27,a61
2010-10-27,a7
2010-10-27,a74
2010-10-27,a8
2010-10-27,a88
2010-10-27,a9
2010-10-27,a94
then your first query counts these, so it produces 1 row of output consisting of 1 column (containing the number 29, which is the number of rows in the subquery)
your second subquery produces this –
SELECT app, mat FROM tbl_acc
WHERE DATES = '2010-10-27'
GROUP BY app, mat
app,mat
262,a53
AG,a16
AM,a0
AS,a38
CS,a0
D,a53
DI,a08
DP,a14
DV,a94
GA,a12
GA,a16
GA,a30
GA,a31
GA,a42
GA,a5
GS,a08
hp,a0
hp,a13
hp,a16
hp,a2
hp,a27
hp,a28
hp,a36
hp,a38
hp,a5
hp,a53
hp,a59
hp,a7
hp,a74
hp,a94
LU,a13
LU,a53
MN,a5
MN,a53
MN,a74
NI,a2
NI,a53
PT,a09
PT,a2
PT,a41
PT,a88
PT,a9
QI,a1
QI,a44
QI,a53
QI,a61
QT,a53
RA,a53
RP,a60
RT,a16
RT,a28
RT,a7
RT,a8
ST,a53
TT,a53
VE,a53
VS,a53
VS,a94
now the second query uses this data, but it produces one row for every app –
SELECT app, count(mat) NAcc
FROM (SELECT app, mat FROM tbl_acc
WHERE DATES = '2010-10-27'
GROUP BY app, mat) q1
GROUP BY app
ORDER BY NAcc DESC
app,NAcc
hp,14
GA,6
PT,5
QI,4
RT,4
MN,3
VS,2
LU,2
NI,2
GS,1
VE,1
262,1
AG,1
AM,1
AS,1
CS,1
QT,1
D,1
RA,1
DI,1
RP,1
DP,1
DV,1
ST,1
TT,1
so the second query produces 25 rows of output consisting of 2 columns
please explain why you think the two queries should poroduce the same result