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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 help with select statement

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2004-10-28 : 13:53:16
Hi! I have the following select statement (which people from this forum helped me with -Thanks!)

I'm having trouble adding another condition to the where clause.

Here's the statement:
		SELECT mydate, [source], countofsourceid FROM ( SELECT Sources.source, COUNT(users.filesource) AS CountOfSourceID, DATEADD(Day, DATEDIFF(Day, 0, users.mydate), 0) AS mydate FROM Sources RIGHT OUTER JOIN users ON Sources.SourceID = users.filesource GROUP BY Sources.source, DATEADD(Day, DATEDIFF(Day, 0, users.mydate), 0), users.Isdouble HAVING users.Isdouble = 0 ) T where myDate ='20041024' 


I want to ad where country='US' but whereever I put it I still get errors. Where's the right place to add it? (country is in the user table)

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-10-28 : 13:57:27
will this be ok?


SELECT mydate, [source], countofsourceid
FROM (
SELECT Sources.source, COUNT(users.filesource) AS CountOfSourceID, DATEADD(Day, DATEDIFF(Day, 0, users.mydate), 0) AS mydate
FROM Sources
RIGHT JOIN users ON Sources.SourceID = users.filesource and users.Country = 'US'
GROUP BY Sources.source, DATEADD(Day, DATEDIFF(Day, 0, users.mydate), 0), users.Isdouble
HAVING users.Isdouble = 0 ) T
where myDate ='20041024'




Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -