So I created an app and I need to go and update all of the very first log entries.
The app collects devices and when you add a device it writes a log entry. The status of the log entry is "in" and then the device can be checked in or out over and over. It is basically an inventory application. However, I'm trying to figure out how to count how many phones are checked out and be able to do it historically.
So I want to count all the IN's then get a count of all the OUT's subtract the two and you have how many are out. HOWEVER - since I have the initial entry as "IN" then it shows like 1600 devices checked in and only 200 out so it says -1400 are checked out. If I can update all the initial entries to "Added" or "Initial" then i believe it will work.
This is the select query... What I need to do is something along the lines of:
I just can't wrap my head around it. I only want to update the very first entry for each device id.
any ideas?
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008
The app collects devices and when you add a device it writes a log entry. The status of the log entry is "in" and then the device can be checked in or out over and over. It is basically an inventory application. However, I'm trying to figure out how to count how many phones are checked out and be able to do it historically.
So I want to count all the IN's then get a count of all the OUT's subtract the two and you have how many are out. HOWEVER - since I have the initial entry as "IN" then it shows like 1600 devices checked in and only 200 out so it says -1400 are checked out. If I can update all the initial entries to "Added" or "Initial" then i believe it will work.
Code:
SELECT [ID]
,[USER_ID]
,[DEVICE_ID]
,[ACTION]
,[DATE_TIME]
FROM [SQA_bsd_qa_db].[dbo].[AMA_Device_History]
This is the select query... What I need to do is something along the lines of:
update [SQA_bsd_qa_db].[dbo].[AMA_Device_History]
where min(date_time]
group by [device_id]
I just can't wrap my head around it. I only want to update the very first entry for each device id.
any ideas?
- Matt
"If I must boast, I will boast of the things that show my weakness"
- Windows 2003 Server, 98 SE, XP
- VB.NET, VSTS 2010, ASP.NET, EXCEL VBA, ACCESS, SQL 2008