Solved

Count Number of rows per day in Sybase database

Posted on 2004-09-08
4
406 Views
Last Modified: 2008-02-26
I have a very big table in my sybase database.
I need to count the number of rows for the last 7 days.

Could you please help me with a simple sql script.
This query should check the last date and calculate the number of rows for the 7 previous date.

Thanks a lot
Abdel
0
Comment
Question by:abidar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 250 total points
ID: 12012244
SELECT Count(*)
FROM YourTableName
WHERE YourDateColumn >= DateAdd(d,-7,GetDate())
0
 
LVL 15

Expert Comment

by:jdlambert1
ID: 12012264
GetDate() is the T-SQL function to return the current system time. DateAdd is the function to add or subtract from datetime values. So the query above subtracts 7 days from the current date, then checks your date column to see if it's later than that. Anything counted will be in the last 7 days. With a lot of records, it will help to create an index on the date column like this:

CREATE INDEX index_on_MyDateColumn ON MyTableName(MyDateColumn)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question