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 |
shakthiA
Starting Member
12 Posts |
Posted - 2009-03-09 : 06:05:24
|
Hi I want to select the members who have not published since their registration.I was doing the Select like below but it is giving me always the all users with noofpublications when I try to put a condition I could build the sql statement. Could anyone please tell meSELECT U.Username, M.CreateDate, M.Email, (SELECT COUNT(S.PUB_ID) FROM Pub P, SHELF S WHERE P.PUB_ID = S.PUB_ID AND ) AS NoOfPubs FROM Profile DP INNER JOIN Users U ON U.UserId = DP.UserIdINNER JOIN Membership M ON M.UserId = DP.UserId AND IsApproved = 1 AND DATEDIFF(D,M.CreateDate,GETDATE()) <= 30Here I tried to put ((SELECT COUNT(S.PUB_ID) FROM Pub P, SHELF S WHERE P.PUB_ID = S.PUB_ID AND ) < 1) AS NoOfPubs instead of (SELECT COUNT(S.PUB_ID) FROM Pub P, SHELF S WHERE P.PUB_ID = S.PUB_ID AND ) AS NoOfPubs But it not working.Can anyone help me.Thanks in advance, |
|
guptam
Posting Yak Master
161 Posts |
Posted - 2009-03-09 : 18:36:43
|
What field is common between Pub and your main tables? If you can list table structure of each table; with sample entries it makes it easier to help. Thanks.-- Mohit K. GuptaB.Sc. CS, Minor JapaneseMCITP: Database AdministratorMCTS: SQL Server 2005http://sqllearnings.blogspot.com/ |
 |
|
|
|
|