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
 Problems with string and date

Author  Topic 

alex.haller
Starting Member

3 Posts

Posted - 2009-08-07 : 13:08:14
Hy, i have this select:

SELECT SOURCE, COUNT(*) FROM table
WHERE SOURCE <>'%SD%'
GROUP BY SOURCE
ORDER BY 2 DESC

But in the results, this collumn shows all entries with SD.

And I want do select the last 30 days from today, for the select above.

Somebody can help me????

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-07 : 13:10:57
your where clause should be:
Source NOT LIKE '%SD%'

Be One with the Optimizer
TG
Go to Top of Page

alex.haller
Starting Member

3 Posts

Posted - 2009-08-07 : 13:21:22
OH THANKS......

AND COULD YOU HELP ME WITH ANOTHER ONE????
I NEED TO SELECT THE LAST 30 DAYS FROM TODAY, I REALLY HAVE NO IDEA HOW TO DO THIS.
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-07 : 13:25:01
where datediff(day, <yourDateColumn>, getdate()) between 0 and 30

Be One with the Optimizer
TG
Go to Top of Page

alex.haller
Starting Member

3 Posts

Posted - 2009-08-07 : 13:34:21
ok, thanks a lot TG, it works...
Go to Top of Page
   

- Advertisement -