Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: How to Return Moving Differences with Grouping?

Started 2 months, 1 week ago by zethon
I'm not even sure if that is the correct terminology, so let me start with some sample data. Say I have a table "data" with colums "id", "datetime", "total". Say the data looks something like ID DATE TOTAL 1 2009-10-01 00:00:00 10 2 2009-10-01 01:00:00 15 3 2009-10-01 02:00:00 17 4 2009-10-01 03:00:00 19 5...
Site: dBforums - Database Support Community  dBforums - Database Support Community - site profile
Forum: ANSI SQL  ANSI SQL - forum profile
Total authors: 2 authors
Total thread posts: 2 posts
Thread activity: no new posts during last week
Domain info for: dbforums.com

Other posts in this thread:

JarlH replied 2 months, 1 week ago
Why do you want 2009-10-04 10 to be returned? That day has only one total-value. For the rest of the rows the following query returns the result you are asking for: SELECT date, MAX(total) - MIN(total) FROM tablename GROUP BY date Note that DATE is a reserved word in ANSI SQL. It's a good idea to avoid reserved words as column names. (Or do at least double quote them, i.e "...

 

Top contributing authors

Name
Posts
JarlH
1
user's latest post:
How to Return Moving Differences...
Published (2009-10-14 03:02:00)
Why do you want 2009-10-04 10 to be returned? That day has only one total-value. For the rest of the rows the following query returns the result you are asking for: SELECT date, MAX(total) - MIN(total) FROM tablename GROUP BY date Note that DATE is a reserved word in ANSI SQL. It's a good idea to avoid reserved words as column names. (Or do at least double quote them, i.e "DATE".)
zethon
1
user's latest post:
How to Return Moving Differences...
Published (2009-10-13 12:58:00)
I'm not even sure if that is the correct terminology, so let me start with some sample data. Say I have a table "data" with colums "id", "datetime", "total". Say the data looks something like ID DATE TOTAL 1 2009-10-01 00:00:00 10 2 2009-10-01 01:00:00 15 3 2009-10-01 02:00:00 17 4 2009-10-01 03:00:00 19 5 2009-10-01 04:00:00 21 6 2009-10-02 00:00:00 25 7 2009-10-02...

Related threads on "dBforums - Database Support Community":

Related threads on other sites:

Thread profile page for "How to Return Moving Differences with Grouping?" on http://www.dbforums.com. This report page is a snippet summary view from a single thread "How to Return Moving Differences with Grouping?", located on the Message Board at http://www.dbforums.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity