Hello,
I have 4 columns with the data below
booktype, bookno, pageno, numofpages
DEED 100 1 5
DEED 100 6 4
DEED 100 10 1
DEED 100 11 2
DEED 100 14 1
DEED 101 1 2
DEED 101 3 4
DEED 101 7 5
Based on this data I know that book 100 page 1 is 5 pages long. So the next page has to be page 6. It is 4 pages long so the next page has to be 10....and so on.
Notice that page 11 is 2 pages long. The next page should be 13, but it's actually 14. This tells me that a page is missing at book 100 page 11.
I am looking for a way that I can identify instances like this. Maybe insert another column to flag if the math doesn't add up.
I could go two ways with the math:
page 1 + 5 pages = 6(the next page). If that is not true, flag the column.
OR page 6(2nd line) - 5 (numofpages from the previous line) - 1 (pageno from the previous line) should always = 0. If it does not, flag the column.
Problem is... I'm not sure how to include the two different rows in the math.
Also, the pages will start over on each book. So the page math will be off at the beginning of each book. I have about 1000 books so hoping I can tell it to do each book as it's own calculation.
I might just have to copy this all to Excel and do it there, but would be much faster if anyone had a SQL solution I could try.
Thanks in advance.
Brian
I have 4 columns with the data below
booktype, bookno, pageno, numofpages
DEED 100 1 5
DEED 100 6 4
DEED 100 10 1
DEED 100 11 2
DEED 100 14 1
DEED 101 1 2
DEED 101 3 4
DEED 101 7 5
Based on this data I know that book 100 page 1 is 5 pages long. So the next page has to be page 6. It is 4 pages long so the next page has to be 10....and so on.
Notice that page 11 is 2 pages long. The next page should be 13, but it's actually 14. This tells me that a page is missing at book 100 page 11.
I am looking for a way that I can identify instances like this. Maybe insert another column to flag if the math doesn't add up.
I could go two ways with the math:
page 1 + 5 pages = 6(the next page). If that is not true, flag the column.
OR page 6(2nd line) - 5 (numofpages from the previous line) - 1 (pageno from the previous line) should always = 0. If it does not, flag the column.
Problem is... I'm not sure how to include the two different rows in the math.
Also, the pages will start over on each book. So the page math will be off at the beginning of each book. I have about 1000 books so hoping I can tell it to do each book as it's own calculation.
I might just have to copy this all to Excel and do it there, but would be much faster if anyone had a SQL solution I could try.
Thanks in advance.
Brian