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 2005 Forums
 Other SQL Server Topics (2005)
 Some basic help...

Author  Topic 

Rea
Starting Member

4 Posts

Posted - 2010-06-09 : 11:39:31
i wrote this query:
SELECT PlayerID,Username
FROM dbo.Players
WHERE PlayMode='p' and CasinoID=5 and (RegistrationDate between 2010-01-01 and 2010-03-31)

it shows no records in the result but i know there supposed to be thousands of records, what did i do wrong?

also, i wrote the query below

SELECT CountryName
FROM (SELECT PlayersName, count(Players.CountryID)as Deposits#
FROM Players,Countries
WHERE CasinoID=12 and DepositsCount<>0
GROUP BY Players.CountryID)
WHERE Deposits#=max(Deposits#)


and got the error:
Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'WHERE'.

when i excute the inner query alone, everything is fine, but when i try to excute it like shown above i get the error, why?

thanks!

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-06-09 : 12:14:09
What is the datatype of RegistrationDate ? Try using YYYYMMDD format for the dates
SELECT PlayerID,Username 
FROM dbo.Players
WHERE PlayMode='p' and CasinoID=5 and (RegistrationDate between '20100101' and '20100331')

There are multiple things not right about the other query. How are Players and Countries related to each other? You have not SELECTED CountryName in your inner query...so the outer query is incorrect.
WHERE Deposits#=max(Deposits#)

This is invalid in a WHERE clause.

POst the table structure, sample data and expected output. We can fix the query for you.
Go to Top of Page
   

- Advertisement -