473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Identify Accounts with Inconsistent Pattern

I have a case where the client wants to know if there a way to catch or flag and account number that does not have daily activity. In the table below you can see that the account had some activity on the 09/01 – 09/04 and then again had some activity on the 09/15 – 09/18. So basically from 09/05-09/14 there was no activity and the clients wants to know how she can create a flag or an indicator that will let her know what this account does not have daily activity.
There will be multiple accounts and there are months that are 30, 31, 24, or 29, days

Can this be done ??


type account
number date
VATSBRNK 153910240974 000000005180 09/01/09
VATSBRNK 153910240974 000000005180 09/02/09
VATSBRNK 153910240974 000000005180 09/03/09
VATSBRNK 153910240974 000000005180 09/04/09
VATSBRNK 153910240974 000000005180 09/15/09
VATSBRNK 153910240974 000000005180 09/16/09
VATSBRNK 153910240974 000000005180 09/17/09
VATSBRNK 153910240974 000000005180 09/18/09
VATSBRNK 153910240974 000000005180 09/25/09
VATSBRNK 153910240974 000000005180 09/26/09
VATSBRNK 153910240974 000000005180 09/28/09
VATSBRNK 153910240974 000000005180 09/29/09
VATSBRNK 153910240974 000000005180 09/30/09
Sep 30 '09 #1
1 1682
Atli
5,058 Expert 4TB
Hey.

Sure, this can be done.

Assuming a table like this:
Expand|Select|Wrap|Line Numbers
  1. +--------+------------+
  2. | client | date       |
  3. +--------+------------+
  4. | No1    | 2009-09-27 |
  5. | No1    | 2009-09-28 |
  6. | No1    | 2009-09-30 |
  7. | No1    | 2009-10-01 |
  8. +--------+------------+
You can see there is a date missing there, 2009-09-29.

To determine the number of missing dates between the first date listed and the last date listed, you could calculate the number of dates actually recorded, and get the number of dates that should be recorded.
The difference between the two would give you the value you need
Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.     `targetCount`-`actualCount` AS `dates missing`
  3. FROM (
  4.     SELECT
  5.         COUNT(DISTINCT `date`) AS `actualCount`,
  6.         MAX(TO_DAYS(`date`)) - MIN(TO_DAYS(`date`)) + 1 AS `targetCount`
  7.     FROM `test`
  8.     WHERE `client` = 'No1'
  9. ) AS `d`;
That would give you the number of days missing, which would be 1 in this case.
Oct 1 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: mongoose7 | last post by:
Hello everyone. I wrote a small class to keep some global variables updated. I use a static method to get the single instance of this class in 2 places in the code. In one place the global...
1
by: Peter Steele | last post by:
I've created an unmanaged C++ DLL and when I compile it I get numerous errors of the form xyz.cpp(nnn): warning C4273: '<somefunction>' : inconsistent dll linkage I have other DLLs that have...
5
by: Greg Cyrus | last post by:
Hi, i recently joined an online.game which rules is not to use 2 diffenrent accounts on one computer. My girlfriend also wants to play - but we got 1 computer only - so I tried to trick the...
3
by: John | last post by:
I am not sure if it is the right forum for Regex topic. If not, please point me the right forum. For a given HTML, I need to identify each asp.net server control. I am not an expert in regex, can...
3
by: blue875 | last post by:
Ok, I've tried searching, and haven't found the answer, so it must mean everyone else but me already knows this. I have an Access 2000 form that I want to connect to an Access 2000 table in the...
3
by: codeman | last post by:
Hi all Lets say we have two tables: Customer: Customer_number : Decimal(15) Name : Char(30) Purchase: Purchase_number : Decimal(15)
3
by: angelnjj | last post by:
I'm going to do my best to describe purpose and what I need...here goes. I'm writing a data entry "quality" report and working. I'm trying to identify anytime a user adds a new contact to the db...
3
by: Rahul Babbar | last post by:
Hi All, When could be the possible reasons that could make a database inconsistent? I was told by somebody that it could become inconsistent if you " force all the applications to a close on...
0
by: johnthawk | last post by:
In the below code setting cell to inconsistent sets entire column inconsistent (renderer).However, I need a third state off | on | inconsistent . How can I change one path->cell? Any help...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.