Top of each item by date.

Posts   
 
    
bvalle
User
Posts: 54
Joined: 07-Jun-2006
# Posted on: 25-Sep-2007 00:36:05   

Hello

The info that you need: Adapter LLBLGen Pro 2.0.0.0 Final February 14th MS SQL 2005

Here are what I have for the databases.

Enterprise (database) Device (table) DeviceID (field) DeviceType (field)

Zone(database) Consumption (table) DeviceID (field) DateTime (field) Measure (field)

What I am able to do right now is get a DeviceType get all devices for that DeviceType, then go to Zone get the date range that I need and get all the measurements for all devices that match the initial device Type. I in fact only really need the top of the date. For example I want the last reading for the date of 9/30/2007, in this case it might return me the current reading on 9/24/2007 (today's date), but I still need one for each device that I pulled.

Right now I am getting the entire date range for September and sorting by date and getting the last record for each device, but this approach as you can probably image can get really troublesome when I start having 1,500 devices each with about 15,000 readings per month.

Could you point me to the correct way of doing this without doing a fetch for each device? But instead doing a top sorting by date and getting the last date in the range?

I hope the above makes sense.

Please let me know.

Thank you, Bruno Valle

bvalle
User
Posts: 54
Joined: 07-Jun-2006
# Posted on: 25-Sep-2007 00:51:11   

Sorry, I put this on the wrong group.

Nevermind this thread. I will create one on the correct group.