Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Confusing query

Author  Topic 

Detox
Starting Member

1 Post

Posted - 2012-01-04 : 15:50:25
Hello All!

I would like to "polish" a query I made. It searches for appointments that have not happened in the past 60 days. It would really be great to also show the last appointment kept.
Here is the code i am using now:

SELECT cg.gruppe_name, cg.crecordnumber, cg.client_name, cg.reason, n.date_service FROM client_gruppe cg
LEFT JOIN notes n ON cg.crecordnumber = n.crecordnumber AND DATE(n.date_service) >= NOW() -60
WHERE cg.gruppe_name <>'ZAPPED' AND n.crecordnumber IS NULL

It asks for all clients except those in a group named ZAPPED. The date of the appointment is n.date_service.

I do not know how I can search for people who have not been here in past 60 days, but show the last time they were actually here.

Is there a way to do this?

Thanks for any suggestions

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-01-04 : 17:01:13
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-04 : 17:25:33
I know a lot of people who "Polish" a query....

Sorry to my Slavic friends

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -