{$page}
Explanation of SQL
This SQL will give you a list of all Miscellaneous (non-order) Receipts “Income” for the specified time period.
Risk of Data Corruption if Run Improperly
None. This is a selection query and no data is modified in the running of it.
SQL
Declare @MinDate datetime; – Set the absolute earliest date you want to query
Declare @MaxDate datetime; – Set the absolute latest date you want to query
SET @MinDate = Convert(DateTime, );
SET @MaxDate = Convert(DateTime, );
–SET @MinDate = '1/26/2011';
–SET @MaxDate = '12/26/2011 11:59:59 PM';
SELECT
A.CompanyName as Company
,J.Description
,GL.EntryDateTime as [Date Posted]
,E.LastName + ', ' + FirstName as [Posted By]
,-(GL.Amount) as Income
,GLA.AccountName as [Income Account]
,J.Notes as [Receipt Notes]
,(SELECT AccountName FROM Payment P WITH(NOLOCK)
LEFT JOIN PaymentAccount PA WITH(NOLOCK) ON P.PaymentAccountID = PA.ID
WHERE P.ID = GL.JournalID
) as [Payment Type]
,(SELECT AccountName FROM Payment P WITH(NOLOCK)
LEFT JOIN GLAccount GLA1 WITH(NOLOCK) ON P.BankAccountID = GLA1.ID
WHERE P.ID = GL.JournalID
) as [Bank Account]
FROM GL WITH(NOLOCK)
LEFT JOIN Account A WITH(NOLOCK) ON A.ID = GL.AccountID
LEFT JOIN Journal J WITH(NOLOCK) ON J.ID = GL.JournalID
LEFT JOIN GLAccount GLA WITH(NOLOCK) ON GLA.ID = GL.GLAccountID
LEFT JOIN Employee E WITH(NOLOCK) ON E.ID = J.EmployeeID
WHERE GL.JournalClassTypeID = 20038
AND GL.GLClassificationType BETWEEN 4000 and 4999
AND GL.EntryDateTime BETWEEN @MinDate and @MaxDate
ORDER BY GL.EntryDateTime, GL.JournalID
Version Information
- Entered : 09/09/2011
Related SQLs
- Backlinks include_pagepage_componentbacklinks