在報表中使用SQL的current_date函數可以方便地獲取當前日期,常用于生成當天的報表數據或篩選出特定日期范圍內的數據。以下是在報表中應用SQL current_date函數的一些技巧:
SELECT * FROM table_name WHERE DATE(date_column) = current_date
SELECT * FROM table_name WHERE date_column >= current_date - INTERVAL '1 week' AND date_column <= current_date
SELECT SUM(sales_amount) FROM table_name WHERE DATE(date_column) = current_date
SELECT 'Daily Sales Report - ' || current_date AS report_title