tsql - Select start time between start and end time -


i want fetch start time should not in between start , end time (fetching reference of table). ve tried getting error. can me on this.?

select distinct right(start_time,7) st_time session_info coursename = 'java'   , (right(start_time,7) not in between          (select right(start_time,7)           session_info           session_id in               (select session_id                sessions                userid='a')) ,          (select right(end_time,7)           session_info           session_id in               (select session_id                sessions                userid='a'))) 

also reusing same query (select session_id sessions userid='a') how store in variable?

you can rewrite code like

select  distinct right(start_time,7) st_time    session_info   coursename = 'java'         , session_id in (select session_id sessions userid = 'a')         , not (right(start_time,7) between right(start_time,7) , right(end_time,7)) 

or using cte

;with mysessionids (session_id) (     select  session_id        sessions       userid = 'a' ) select  distinct right(si.start_time,7) st_time    session_info si         inner join mysessionids             on si.session_id = mysessionids.session_id   si.coursename = 'java'         , not (right(start_time,7) between right(start_time,7) , right(end_time,7)) 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -