Select time not in 3 Sessions in another table
-
Monday, February 20, 2012 12:11 PM
trying to select count when the fColorGridGenAt is not between Session A = 9.00 - 10.00
Session B = 14.00 - 15.00 & Session C = 17.00 - 18.00
table 1 = tColorGridSession
table 2 = tColorGridDailyGenLog
fColorGridStartTime = time(7)
fColorGridGenAt = datetimebut the following had error,
Select COUNT(tcgs.fColorGridGenLogID) FROM tColorGridSession tcgs, tColorGridDailyGenLog tcg WHERE (tcgs.fColorGridGenAt NOT BETWEEN tcgs.fColorGridStartTime AND tcgs.fColorGridEndTime WHERE tcgs.fColorGridSessionName = 'A') AND (tcgs.fColorGridGenAt NOT BETWEEN tcgs.fColorGridStartTime AND tcgs.fColorGridEndTime WHERE tcgs.fColorGridSessionName = 'B') AND (tcgs.fColorGridGenAt NOT BETWEEN tcgs.fColorGridStartTime AND tcgs.fColorGridEndTime WHERE tcgs.fColorGridSessionName = 'C')
All Replies
-
Monday, February 20, 2012 2:18 PM
I don't understand your query.
There are a lot of error's in your query.
- Where did you Equate tcgs and tcg tables. (i.e joined the tables on a column)
- Why do you use "tColorGridDailyGenLog tcg" table when you haven't used it any where.
- There are syntactical errors in your query. Why are you using WHERE keyword multiple times.
I tried a query but it seems that it is misleaded by insufficient information.
Please clarify on these issues so that we can provide a solution. Provide table create and sample data scripts.
Planet Earth is at risk. Global warming is on a high tide.
Take Responsibility. Plant Trees. Keep your City Clean and Green.Mark all Helping Posts and Close your Threads. Keep the Forum Green.
- Arun Kumar Allu- Marked As Answer by Ed Price - MSFTMicrosoft Employee, Owner Wednesday, January 16, 2013 9:22 PM

