return to tranceaddict TranceAddict Forums Archive > Main Forums > Chill Out Room

 
anyone know SQL?
View this Thread in Original format
JohnSmith
Hello, this is my first post here, i hope that someone can help me out.

I have a pretty complex SQL query, which is supposed to return a count of how many items are within a given time period.

however, there is a little "twist" to this, the items can open and close. so they have to be open during the period in question.

which means, that there is one of 5 possible criteria that will satisfy this, either they:

open before, and close after the period
open before, and close within the period
open within, and close within the period
open within, and close after the period

so, this is the SQL that i was using:

SELECT COUNT(*) FROM TBL_BQDATA WHERE ((DATA_ADDEDDATETIME > 6/1/2002 AND Closed_DATE <= 6/30/2002) OR (DATA_ADDEDDATETIME <= 6/1/2002 AND Closed_DATE > 6/30/2002) OR (DATA_ADDEDDATETIME <= 6/30/2002 AND Closed_DATE > 6/30/2002 AND DATA_ADDEDDATETIME > 6/1/2002) OR (DATA_ADDEDDATETIME <= 6/1/2002 AND Closed_DATE <= 6/30/2002 AND Closed_DATE > 6/1/2002)) AND (DATA_ADDEDDATETIME <= Closed_DATE);

The logic seems to be solid, but, i get no rows back. I have verified that there is in fact data in the table. I tried running this in the query builder in MS-Access 2002, and i got no results back as well. I took a screen shot to be clear, it shows the table data, as well as the query, one version nicely formatted, and one of just raw characters.



why don't i get anything back?

Why won't this select Query return any rows?
CLICK TO RETURN TO TOP OF PAGE
 
Privacy Statement