Saturday, November 1, 2014

Fixed Asset Transaction Analysis - Transaction per day - SQL

Recently, I answered a forum post for a user who wanted to know the number of transactions by module entered in a given day.  I authored a series of queries which allow a user to input a date and execute the query. 

The queries identify the number of unique transactions and the number of lines in the table. Dividing one by the other will reveal the average lines per transaction.  

The Fixed Asset tables presented a unique challenge.  Transactions are written to the FA00902 table, and have either been interfaced with the General Ledger or not, so there is no easy way to identify transactions for a specific date. 

I came up with an approach I think works best.  The following queries return Transactions Not Interfaced with the GL - these all have the same GL Interface Date (GLINTTRXDATE) value of 1900-01-01 00:00:00.000. Transactions that have already been interfaced with the GL can be identified by a specific date, but will generally have been interfaced at a month-end.

This query reveals the Number of Fixed Asset Transactions, which have not been interfaced with the GL and interfaced transactions on a given day, as well as the number of overall lines.

/* Fixed Asset Transactions NOT Interfaced with GL */
select COUNT(FA_Trxs) FA_Trxs from (
select count(FA_Doc_Number) FA_Trxs from FA00902
Where GLINTTRXDATE = '01/01/1900'
Group by FA_Doc_Number ) FAT
/* Fixed Asset Transaction Lines NOT Interfaced with GL */
Select COUNT(FA_Doc_Number) FA_Trx_Lines from FA00902
Where GLINTTRXDATE = '01/01/1900'

DECLARE @Date as DATETIME
Set @Date = '12/31/2016'

/* Fixed Asset Transactions Interfaced with GL */
select COUNT(FA_Trxs) FA_Trxs from (
select count(FA_Doc_Number) FA_Trxs from FA00902
Where GLINTTRXDATE = @Date
Group by FA_Doc_Number ) FAT
/* Fixed Asset Transaction Lines Interfaced with GL */
Select COUNT(FA_Doc_Number) FA_Trx_Lines from FA00902
Where GLINTTRXDATE = @Date

No comments:

Post a Comment