SQL NOW
Postgres's shorter, function-call alias for CURRENT_TIMESTAMP — identical behavior, different syntax.
What & Why
In PostgreSQL, NOW() is equivalent to CURRENT_TIMESTAMP and is stable for the transaction. The worked query fixes the timestamp while counting the real product.features rows.
See How It Works
BUSINESS QUESTION
Using a fixed teaching clock, Product records a report timestamp beside the feature count.
| id | name | description | team | released_at | deprecated_at |
|---|---|---|---|---|---|
| 1 | Activation Checklist | Guides new users through setup | growth | 2024-01-20 | NULL |
| 2 | CSV Export | Exports report data | platform | 2024-02-14 | NULL |
| 3 | Invite Nudges | Prompts workspace collaboration | growth | 2024-03-05 | NULL |
| 4 | Legacy Dashboard | Original reporting surface | analytics | 2023-08-10 | 2024-06-01 |
EXAMPLE QUERY
-- In a live report, replace the teaching value with NOW().
SELECT
TIMESTAMPTZ '2024-03-31 12:00:00+00' AS checked_at,
COUNT(*) AS feature_count
FROM product.features;RESULT — exact output from the displayed Queryflo rows
| checked_at | feature_count |
|---|---|
| 2024-03-31 12:00:00+00 | 4 |
The fixed timestamp represents NOW() beside the real feature count.
Now You Try
Practice this concept
Return the fixed teaching timestamp 2024-03-31 12:00:00+00 beside the product.features row count.
Available schema
productPrefix tables with product.table_name.
checked_atfeature_countproduct.features| Column | Type |
|---|---|
| id | integer |
| name | text |
| description | text |
| team | text |
| released_at | timestamp with time zone |
| deprecated_at | timestamp with time zone |
| internal_priority | integer |
query.sql
Sign up free to try it on a real business scenario