This SQL for using some purpose but even i give a sort clause(order by tdate) still it is not sorting date wise. how to rewrite to get 'tdate' column sorted:
SELECT TOP 100 PERCENT *
FROM (SELECT TOP 100 PERCENT tdate,
parti,
Abs(Sum(amtdr)) AS Dr,
Sum(amtcr) AS Cr,
nart
FROM dbo.dbo_dayb a
WHERE ( account = 'bank' )
GROUP BY idno,
tdate,
parti,
nart
UNION ALL
SELECT tdate,
parti,
amtdr,
amtcr,
nart
FROM dbo.dbo_dayb
WHERE ( account = N'PDC account' )
AND ( post = N'Cr' )) DERIVEDTBL
ORDER BY tdate