Subject | RE: [firebird-support] QUERY QUESTION |
---|---|
Author | Louis van Alphen |
Post date | 2017-03-02T20:26:03Z |
Select itemnr,count(*) as days
From table
Group by itemnr,cast(dateused as date)
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com]
Sent: 02 March 2017 06:37 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] QUERY QUESTION
Importance: High
Good day,
I have a question for you SQL boffins, how can I query a table to get the
count of consecutive days found ?
A Table contains rows with dates where an item(s) has been added for every
day this item was used.
i.e.
itemnr dateused
abc 2017/02/01
abc 2017/02/02
abc 2017/02/25
abc 2017/02/25
abc 2017/02/25
abc 2017/02/26
abc 2017/02/27
abc 2017/02/28
abc 2017/03/01
abc 2017/03/02
The result from above sample should be 6 as there is a break between
2017/02/02 and 2017/02/25?
Regards
Stef
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
From table
Group by itemnr,cast(dateused as date)
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com]
Sent: 02 March 2017 06:37 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] QUERY QUESTION
Importance: High
Good day,
I have a question for you SQL boffins, how can I query a table to get the
count of consecutive days found ?
A Table contains rows with dates where an item(s) has been added for every
day this item was used.
i.e.
itemnr dateused
abc 2017/02/01
abc 2017/02/02
abc 2017/02/25
abc 2017/02/25
abc 2017/02/25
abc 2017/02/26
abc 2017/02/27
abc 2017/02/28
abc 2017/03/01
abc 2017/03/02
The result from above sample should be 6 as there is a break between
2017/02/02 and 2017/02/25?
Regards
Stef
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]