Hello Group,
I have a table that has 3 columns:
ID (int), datetime, Value(varchar)
ID = ID for the SNMP device
datetime = time record was added
value = value added for that device.
This table contains sample # values taken from a device (SNMP) every 5
minutes.
I would like to issue a Select query that would do the following:
For each ID, find the first and last values for a given date range (Ex:
First and Last values for July),
Then subtract the latest value from the previous value for that same ID.
Similar to a power meter on your house, finding the reading on the meter at
the first day of the month, and the last day of the month to calculate usage
for that month.
Thanks For the help.
Please post on group. 5 1291
Got2Go wrote: I would like to issue a Select query that would do the following:
For each ID, find the first and last values for a given date range (Ex: First and Last values for July), Then subtract the latest value from the previous value for that same ID.
select
min(value),
max(value),
max(value)-min(value)
from tablename
where date_ >= '2004-01-01'
and date_ <= '2005-01-01'
group by id;
Hi Aggro,
Thanks for the suggestion.
This does not seem to do what I needed.
It looks for the highest and lowest values for a given date range.
But what I need is the first value and last values for the given date range.
First and last based on date, and not the actual value.
Any other ideas ?
Thank You.
"Aggro" <sp**********@y ahoo.com> wrote in message
news:Yg******** *******@read3.i net.fi... Got2Go wrote:
I would like to issue a Select query that would do the following:
For each ID, find the first and last values for a given date range (Ex: First and Last values for July), Then subtract the latest value from the previous value for that same ID.
select min(value), max(value), max(value)-min(value) from tablename where date_ >= '2004-01-01' and date_ <= '2005-01-01' group by id;
how do you define first and last? The earliest/last date?
Got2Go wrote: Hi Aggro, Thanks for the suggestion.
This does not seem to do what I needed. It looks for the highest and lowest values for a given date range.
But what I need is the first value and last values for the given date range. First and last based on date, and not the actual value.
Any other ideas ?
Thank You.
"Aggro" <sp**********@y ahoo.com> wrote in message news:Yg******** *******@read3.i net.fi...
Got2Go wrote:
I would like to issue a Select query that would do the following:
For each ID, find the first and last values for a given date range (Ex: First and Last values for July), Then subtract the latest value from the previous value for that same ID.
select min(value), max(value), max(value)-min(value) from tablename where date_ >= '2004-01-01' and date_ <= '2005-01-01' group by id;
Hi David,
Yes, correct.
Given a date range, the first and last records that fall within that date
range. Based on the date of the record.
Thanks for the help!
"David L" <dl@nospam.co m> wrote in message
news:gM******** ***********@new s-server.bigpond. net.au... how do you define first and last? The earliest/last date?
Got2Go wrote: Hi Aggro, Thanks for the suggestion.
This does not seem to do what I needed. It looks for the highest and lowest values for a given date range.
But what I need is the first value and last values for the given date
range. First and last based on date, and not the actual value.
Any other ideas ?
Thank You.
"Aggro" <sp**********@y ahoo.com> wrote in message news:Yg******** *******@read3.i net.fi...
Got2Go wrote:
I would like to issue a Select query that would do the following:
For each ID, find the first and last values for a given date range (Ex: First and Last values for July), Then subtract the latest value from the previous value for that same
ID. select min(value), max(value), max(value)-min(value) from tablename where date_ >= '2004-01-01' and date_ <= '2005-01-01' group by id;
Got2Go wrote: But what I need is the first value and last values for the given date range. First and last based on date, and not the actual value.
Any other ideas ?
If you are using version 4.1 or above, you could use subselects to help
out with the query (I'm pretty sure it is possible, but never tried it,
since I live in the past with version 3.x). If you are using version <
4.1, your options are:
- Use a query with joins (I don't know how to one in this case, and I'm
not even sure if it is possible)
- Run multiple queries. This is the easy way, but most likely the slow
way if you have many devices. You can do this by first finding out the
min and max dates for each device and then selecting values matching them. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Fabiani |
last post by:
Hi,
I'm a newbie and I'm attempting to learn howto create a select statement.
When I use
>>> string1='18 Tadlock Place'
>>> cursor.execute("SELECT * FROM mytest where address = %s",string1)
All works as expected. But
>>> numb=10
>>> cursor.execute("SELECT * FROM mytest where clientID = %d",numb)
Traceback (innermost last):
File "<stdin>", line 1, in ?
|
by: jimh |
last post by:
I'm not a SQL expert. I want to be able to write a stored procedure
that will return 'people who bought this product also bought this...'.
I have a user table that links to a transaction table that links to a
transaction items table that links to the products table:
(User Table)
UserID
Other user data
|
by: Tcs |
last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't
loaded it yet. I'm still using MS Access. And no, I don't believe this is an
Access question. (But who knows? I COULD be wrong... :) I've tried the
access group...twice...and all I get is "Access doesn't like ".", which I know,
or that my query names are too long, as there's a limit to the length of the SQL
statement(s). But this works when I don't try to...
|
by: Andrew McNab |
last post by:
Hi folks,
I have a problem with an MS Access SQL query which is being used in an
Access Report, and am wondering if anyone can help.
Basically, my query (shown below) gets some records from a couple of
tables in my database using INNER JOINS and the WHERE clause to
specify the required constraints. However, I also want to read two
fields from a *single* record from a table called 'Locations' and then
apply one of these field's values...
|
by: Terencetrent |
last post by:
I having been using Access '97/2002 for about 4 years now and have
never really had the need or the time to learn visual basic. Well, I
think the time has finally come.
I need help with Visual Basic code that will examine numeric value for
a particular field in a query, and assign a new numeric vaule to that
field. There are over 21 possible values and I am told that IIF
statement will only handle 9 of the possibilities and that I need...
| |
by: Polly |
last post by:
I had a macro that ran a parameter query and created and opened an
Excel file with the system date as part of the file name, but I had to
change the file name by hand. So I converted the macro to code using
tools-->references.
The converted macro included the following statement:
DoCmd.OutputTo acQuery, "qselLabelsBloodLog_output",
"MicrosoftExcelBiff8(*.xls)", "S:\susan_cheree\lb041129.xls", True,
"", 0
|
by: jjturon |
last post by:
Can anyone help me??
I am trying to pass a Select Query variable to a table using Dlookup
and return the value to same select query but to another field.
Ex.
SalesManID SalesManName
AT Alan Time
|
by: djflow |
last post by:
Hi!
II was wondering if you can help me with SQL query..
Below 7 separated select query works fine(only when they are retrieved separately)
But I want to combined them together and so that i can make report from my database on the one sheet rather than querying each select statement ( I will use MS Query from the Excel)
=========================================================
1)
select convert(varchar, create_date_time, 112) as Date,...
|
by: P3Eddie |
last post by:
Hello all!
I don't know if this can even be done, but I'm sure you will either help or suggest another avenue to accomplish the same.
My problem may be a simple find duplicates / do something with only one of the duplicates issue, but I got to the point where an update query with a nested select subquery would work wonderfully, if only it would work!
I have several fields in a master Access 2000 table, some of which are id, fname,...
|
by: dizzydangler |
last post by:
Hi, I'm new to access (2007, running on XP), but I've gotten some great help from this site on my project so far. However, the more I know, the more complex the problems seem to become....
I'm working with all of my data in a single table and, right now, I've got a form linked to a query that allows the user to input whatever search criteria they want through a variety of controls. I've also created a series of check boxes on the form...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |