473,387 Members | 1,621 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.

How to compare two different columns in two different rows.

I'm completely new to SQL and this puzzle is over my head. Any advice
would be greatly appreciated.

Table: Visits
Columns:
RecNo VisitNo EnterDate
LeaveDate
M1111232 V11112869 2008-09-23 10:25:00.000 2008-09-23 10:31:00.000
M1111232 V11112943 2008-10-24 15:56:00.000 NULL
M1111233 V11112877 2008-09-23 15:53:00.000 NULL

I have a table as described above. It contains several thousand rows
ordered by RecNo by VisitNo.

VisitNo is the key.

If there is only one row for a RecNo, I want to bypass it.

If there is more than one row per RecNo AND
If the row immediately below the current row has the same RecNo as the
first row
I want to compare the Leave Date of the 1st row with the Enter Date of
the 2nd row and calculate the diff. in # of days.

If the number of days is greater than 3, I want to list the two date
values from above and the RecNo. in one row.

How do I do this?

Please help. I am completely befuddled. Thanks, Gabe
Oct 28 '08 #1
0 1968

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
1
by: Prakash RudraRaju | last post by:
Hi, I have recently migrated MSAccess Tables (nearly 120) to MySQL. To test successful migration I want to compare all tables. I have linked MySQL tables through ODBC connection. I want to...
2
by: gibster | last post by:
Hi I'm looking for some help comparing 2 datasets, each dataset has 2 datatables; the first table's rows consist of text status (1 or 0) GUID
4
by: Justin Emlay | last post by:
I have two lists. These can be in either table form or array. That is, my data is in a dataset which I can move to an array if need be. ListA is a master list and it contains all items. ListB...
11
by: inpuarg | last post by:
I have 2 datatables. They are identical. I want to compare them by cell's content. They are all same. But dt1 == dt2 or dt1.GetHashCode() == dt2.GetHashCode() doesn 't work. There are big...
3
by: pochimen | last post by:
Hi everyone, i`m trying to make access interact with excel in vba I have an excel sheet with 3 columns and 30 rows, and an access table of 4000 rows. The idea is to compare every row of the...
7
by: John Wright | last post by:
I have two datatables that I load. One I load from LDAP, the other gets loaded from Excel. I need to check to see which names are in the LDAP that are not in the Excel table and vica versa. ...
5
by: Patrick A | last post by:
All, I need a little help understanding which concepts / functions / methods / strategies I should use to accomplish what I'll describe below. Note - the real implementation isn't about music -...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.