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.
| Author |
Topic |
|
Rea
Starting Member
4 Posts |
Posted - 2010-06-14 : 03:55:24
|
| Hi,I wrote the following code:select Name, count(BrandID)from Players Join Brands on CasinoID where UnsubscribeDate between '2009-01-01' and '2010-01-01'group by BrandID, Namei got this error:Msg 4145, Level 15, State 1, Line 3An expression of non-boolean type specified in a context where a condition is expected, near 'where'.help needed...:)thanks,Rea. |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2010-06-14 : 04:17:02
|
What is on CasinoID? Are you supposed to have a join here??If so, it should probably be:select Name, count(BrandID)from Players PJoin Brands Bon B.CasinoID = P.CasinoIDwhere UnsubscribeDate between '2009-01-01' and '2010-01-01'group by BrandID, Name |
 |
|
|
wormz666
Posting Yak Master
110 Posts |
Posted - 2010-06-14 : 04:20:13
|
quote: Originally posted by Rea Hi,I wrote the following code:select Name, count(BrandID)from Players Join Brands on CasinoID where UnsubscribeDate between '2009-01-01' and '2010-01-01'group by BrandID, Namei got this error:Msg 4145, Level 15, State 1, Line 3An expression of non-boolean type specified in a context where a condition is expected, near 'where'.help needed...:)thanks,Rea.
your lacking in your join statement...your should specify which column should they refer...and also you dont need to group by a column if it is using an aggregate function...sorry but my English is bad,finding the truthmaking a maze on my mind.... |
 |
|
|
Rea
Starting Member
4 Posts |
Posted - 2010-06-14 : 05:12:38
|
| Rick, CasinoID is supposed to be BrandID (my mistake..)wormz, what do you mean by saying that i dont need to group by a column if i use it in an aggregation? which column are you reffering to? |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2010-06-14 : 05:27:22
|
| I think he means BrandID as you are using it as a count. |
 |
|
|
Rea
Starting Member
4 Posts |
Posted - 2010-06-14 : 06:29:21
|
| well, the query works now, and i havne't removed BrandID from the Group by statement.i still don't understand, BrandID is the field i want to group by in order to count, isn't putting it in the group by statement the whole point?? |
 |
|
|
|
|
|
|
|