473,715 Members | 6,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

counting distinct posts by a users within the past 10 days - SQL2005

2 New Member
Hey gang, any help will be apprecited. I am trying to do a simple count of all posts to a message board from a few particular users within the past 10 days.

I know the usernames and number of days that i want to query (10) and I want the output to display as follows....
Manager PostCount
user1 1
user2 14
user3 20
_______________ ____

The query i have is but below but there is two problems with it. They are not being grouped but rather outputing lineitem AND the DATEADD criteria does not seem to affect the result.

Expand|Select|Wrap|Line Numbers
  1. SELECT     PostAuthor, COUNT(PostAuthor) AS PM_Count
  2. FROM         cs_Posts
  3. GROUP BY PostAuthor, PostDate
  4. HAVING      (PostDate = DATEADD(d, - 10, GETDATE())) AND (PostAuthor = N'dclecompte') OR
  5.                       (PostAuthor = N'haley') OR
  6.                       (PostAuthor = N'clapoint')
  7. ORDER BY PostDate DESC, PostAuthor
I am a new guy so I really do appreciate any help that you can provide.
Dec 26 '07 #1
2 1156
ssasser
2 New Member
TRY THIS

Expand|Select|Wrap|Line Numbers
  1. SELECT     COUNT(PostAuthor) AS PM_Post_Count, PostAuthor
  2. FROM         dbo.cs_Posts
  3. WHERE     (PostDate = DATEADD(d, - 10, GETDATE())) OR
  4.                       (PostAuthor = N'haley') OR
  5.                       (PostAuthor = N'clapoint') OR
  6.                       (PostAuthor = N'dclecompte')
  7. GROUP BY PostAuthor

Hey gang, any help will be apprecited. I am trying to do a simple count of all posts to a message board from a few particular users within the past 10 days.

I know the usernames and number of days that i want to query (10) and I want the output to display as follows....
Manager PostCount
user1 1
user2 14
user3 20
_______________ ____

The query i have is but below but there is two problems with it. They are not being grouped but rather outputing lineitem AND the DATEADD criteria does not seem to affect the result.

Expand|Select|Wrap|Line Numbers
  1. SELECT     PostAuthor, COUNT(PostAuthor) AS PM_Count
  2. FROM         cs_Posts
  3. GROUP BY PostAuthor, PostDate
  4. HAVING      (PostDate = DATEADD(d, - 10, GETDATE())) AND (PostAuthor = N'dclecompte') OR
  5.                       (PostAuthor = N'haley') OR
  6.                       (PostAuthor = N'clapoint')
  7. ORDER BY PostDate DESC, PostAuthor
I am a new guy so I really do appreciate any help that you can provide.
Dec 26 '07 #2
amitpatel66
2,367 Recognized Expert Top Contributor
TRY THIS

Expand|Select|Wrap|Line Numbers
  1. SELECT     COUNT(PostAuthor) AS PM_Post_Count, PostAuthor
  2. FROM         dbo.cs_Posts
  3. WHERE     (PostDate = DATEADD(d, - 10, GETDATE())) OR
  4.                       (PostAuthor = N'haley') OR
  5.                       (PostAuthor = N'clapoint') OR
  6.                       (PostAuthor = N'dclecompte')
  7. GROUP BY PostAuthor
Is it working now or still facing an issue??
Dec 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7167
by: Ike | last post by:
How can I make a query such that in the "WHERE" part of my clause, I want to put something to the effect that, say, X days have elapsed since a given date. For example, suppose in my table, I have a boolean field and a date field. I want to create a query asking for those rows where X days have elapsed from the date field in a row and the boolean, say, is false. Do I need to create a third field, called, say "X" for how many days have...
2
488
by: Mark Jerzykowski | last post by:
Hi, I have a log table which contains the fields log_time (DATETIME) and session_id (VARCHAR). Using these 2 columns I want to be able to SELECT the number of users who have been online during the past hour. Getting the number of rows logged in the last hour is easy but I can't work out how to only count distinct session_id entries. Thanks,
5
2692
by: Cam Bevis | last post by:
I'm having trouble getting my head around this, and no one in the groups has posted exactly the problem. The table below tracks site traffic across a network. There is 1 row per pageview and UUID is that user's unique cookie. CREATE TABLE . ( NOT NULL , NULL , NULL ,
2
1666
by: calan | last post by:
Having a brainfart.... I need a query that returns a record count, based on two distinct fields. For example: Order Revision Customer 001 1 Bob 001 2 Bob 002 1 John
1
14490
by: nfrodsham | last post by:
In Microsoft's help literature, it states: "You can filter out non-unique rows by using the DISTINCT option of an aggregate function" I am trying to do this in Access 2003 with the COUNT aggregate function, but there is no reference, at least that I can find anywhere, of how to do this. I have multiple lines fields for which I would like to do a "count distinct", but for simplicity, I am showing an example of only one field. Here is...
6
2168
by: MLH | last post by:
I'm tired of reading the fine print! Too many registrars out there. So I'm asking this group for a little help. I'm looking for a Registrar who will do an honest day's work for a fair price. I'm tired of Registrars who build in "gotchas" into their service offering that nab you for something more than you bargain for - including the right to screw you later in their fine print. I want a registrar who won't charge you to leave them....
2
1732
by: jason.teen | last post by:
Hi I have this scenario: group | id | value --------------------------------- x | location | QLD x | location | NSW x | location | VIC x | location | VIC
1
1390
LMHelper
by: LMHelper | last post by:
Ok I am creating a new database for LM. One that will keep track of our licenses for over 400 users. We already have a database with the users information like name, location, telephone number, employee ID. In the licensing database so far I have created a table explaining the licensing information and gave each application a code so that each person will have that code listed in their table to reflect what software they have. I have a form...
2
2837
by: vspsdca | last post by:
Hi, I'm quite new to the world of VBA so any help you could extend will help me a lot with my project. I have a database of Change Requests from our users. I have two date boxes, one is Date Request Raised and Deadline for Entry. What I'd like to happen is when I enter the date on the Date Request Raised the Deadline for Entry would automatically be filled based on the Asset type that was selected. For example: if the asset type = 2...
0
9343
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9198
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9047
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2119
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.