Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 370945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:04:02+00:00 2026-05-12T14:04:02+00:00

I have a file upload site, and I want to run a maintenance script

  • 0

I have a file upload site, and I want to run a maintenance script that will run every day and delete items that haven’t been accessed in a week. I log views for each day, and each item into a table:

  • hit_itemid
  • hit_date
  • hit_views

The main table actually has the files that were uploaded, for the purposes of this example, its just vid_id, vid_title thats in this table, and vid_id will equal to hit_itemid.

I have a query as follows:

 SELECT vid_id, 
        vid_title, 
        SUM(case when hit_date >= '2009-09-17' then hit_hits else 0 end) as total_hits 
   FROM videos
  LEFT JOIN daily_hits ON vid_id = hit_itemid 
  WHERE vid_posttime <= '$last_week_timestamp' AND vid_status != 3
  GROUP BY hit_itemid 
  HAVING  total_hits < 1

But this always returns a single record.

How can I rewrite this query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:04:02+00:00Added an answer on May 12, 2026 at 2:04 pm

    first guess, may be you have to do a

    GROUP BY vid_id
    

    instead of

    GROUP BY hit_itemid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 237k
  • Answers 237k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No, Sphinx doesn't require the mysql database to be 'fulltext'.… May 13, 2026 at 6:31 am
  • Editorial Team
    Editorial Team added an answer For a singleton you should move the definition of container… May 13, 2026 at 6:31 am
  • Editorial Team
    Editorial Team added an answer I think article will help you out. http://lanitdev.wordpress.com/2009/06/08/extending-jquery-to-select-asp-controls/+ I have… May 13, 2026 at 6:31 am

Related Questions

I have a some html being generated by JQuery on a Share Point page.
I have the task to build a web-site for a smaller non-profit organization. I
im trying to use a file upload control from the obout control library, i
In my site, user want to upload a pdf file and I have to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.