SELECT
GL7PROJECTS.[PROJECTID] "Project ID",
DBO.BBConvertSQLDate(T_2.POSTDATE) "Post date",
T_2.[TRANSACTIONNUMBER] "Transaction number",
CASE T_2.TRANSACTIONTYPE WHEN 1 THEN 'Debit' WHEN 2 THEN 'Credit' ELSE '' END "Debit/Credit",
case (select TransactionType from DBO.GL7Transactions where GL7TransactionsID = T_1.GL7TRANSACTIONSID) when 1 Then T_1.AMOUNT else (-1 * T_1.AMOUNT) end "Transaction amount"

FROM
GL7PROJECTS
INNER JOIN DBO.GL7TRANSACTIONDISTRIBUTIONS AS T_1 ON GL7PROJECTS.GL7PROJECTSID = T_1.GL7PROJECTSID
INNER JOIN DBO.GL7TRANSACTIONS AS T_2 ON T_1.GL7TRANSACTIONSID = T_2.GL7TRANSACTIONSID

WHERE
T_2.[POSTDATE] BETWEEN '2008-01-01' AND '2008-12-01 23:59:59.997'

ORDER BY
GL7PROJECTS.PROJECTID,
T_2.POSTDATE