Sort criteria in views: how to add custom one I have added a "node title" field.  I want to add this sort criteria to the node: the number of times the node  has been viewed by visitors in a week, descending.
If I want to add a sort criteria with PHP code and a SQL query to insert in Views module, how should I do?

ps:i have overwritten a field. i want to query the database and using the query to Sort Criteria**how to add the custom one
First, make sure you have Drupal's Statistics module enabled and collecting page view statistics.

In Drupal 6, you need to enable Count content views under admin/reports/settings. This will count total node views and give you total day count. Unfortunately, it does not give you a weekly view count by default.

This will give you a sort criteria for Node statistics: Total views and Node statistics: Views today.

Upon closer inspection of the day count for node views, this value is reset to 0 every 24 hours by statistics_cron. This value would prove more useful as a sort criteria if it was the most recent 24 hour's node views. So, the Node statistics: Total views would be your best bet.

NOTE: See Statistics Granularity module for week, month and year.