The NTILE() function divides sorted rows into a specified number of approximately equal buckets. It's useful for data segmentation, such as:
SELECT NTILE(4) OVER (ORDER BY column_name) AS quartile, *FROM table_name_salesWHERE demographic_column = 'demographic_1'
This query segments the data into quartiles based on the specified column, which can be adjusted for different demographics.