0

Need some help on MYSQL query syntax, I am able to get last 60 records but wanted to exclude this week's record. I am trying following but can't able to figure out correct syntax.

select TIMESTAMP,ID,MAX,MIN from 
 (select TIMESTAMP,ID,MAX,MIN from db 
  where ID = 'A0101'  
  WHERE YEARweek(TIMESTAMP) =! YEARweek(current_DATE) 
  group by TIMESTAMP desc limit 60) t 
order by TIMESTAMP asc
1
  • Is this your query? Two where clause in one select? No error? Commented Aug 11, 2011 at 12:17

2 Answers 2

2
select TIMESTAMP,ID,MAX,MIN from db 
  where ID = 'A0101'  
  AND YEARweek(TIMESTAMP) != YEARweek(current_DATE) 
  group by TIMESTAMP desc limit 60
order by TIMESTAMP asc

more like this...

Sign up to request clarification or add additional context in comments.

Comments

0

Probably it is just the =! which negates YEARweek() and compares to the other YEARweek().

You should try != instead.

Currently, I cannot tell more, as you don't show what is wrong or what happens or doesn't happen with your query.

1 Comment

right. Needs two, three more glances on it - would have been easier to spot if original would be accompagnied by an error message. ("It doesn't work" is none.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.