Link to home
Start Free TrialLog in
Avatar of HangTenDesign
HangTenDesign

asked on

Count total value of an integer field from multiple records

Hello,

I have a field in a table called DAILY_COUNT that holds the value of page hits for a day. The next day a new record is added and begins counting up for that day. How do I write a query that adds up the total of every day into one value.

SELECT TOTAL_OF_ALL_DAYS(daily_count) AS page_hits  --      ;-)
FROM page_count
WHERE page_id = 1
ASKER CERTIFIED SOLUTION
Avatar of mherchl
mherchl
Flag of Slovakia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Scott Pletcher
SELECT SUM(daily_count) AS page_hits  --      ;-)
FROM page_count
WHERE page_id = 1
Avatar of Forbes32
Forbes32

You are nearly there, you need to use SUM on the integer field

SELECT SUM(daily_count) AS page_hits
FROM page_count
WHERE page_id = 1