Intermediate Level Questions
1. Write a query to calculate the running total of sales for each product category in a dataset.
2. Use a CASE statement to create a new column categorizing customers based on their total
spend.
3. Explain the difference between ROW_NUMBER(), RANK(), and DENSE_RANK() functions,
and write examples of each.
4. Write a query to find the top 3 selling products in each region using window functions.
5. Explain the purpose of COLLECT STATISTICS in Teradata and write a query to collect
statistics on a table.
6. Write a query to identify gaps in a sequence of order IDs in a dataset.
7. Perform an inner join between two tables and filter the results where the joined column
values match a specific condition.
8. Write a query to create a derived table and use it in a larger query.
9. Use MERGE INTO to update or insert data into a table from a source table.
10. Explain the difference between PI, PPI, and UPI in Teradata.
Advanced SQL Queries
11. Write a query to create a rolling 7-day average of sales for each product.
12. Explain the use of QUALIFY in Teradata and write an example query using it.
13. Write a query to pivot data from rows to columns.
14. Perform an unpivot operation to convert columns into rows.
15. Use WITH recursive queries to find all descendants of a given parent ID in a hierarchical
dataset.
16. Write a query to rank customers based on their year-to-date spend, partitioned by region.
17. Explain the differences between HASH and HASHAMP functions in Teradata and use them in
a query.
18. Optimize a query by replacing an expensive JOIN with an equivalent EXISTS clause.
19. Write a query that identifies duplicate rows in a table and deletes them.
20. Explain the Teradata Primary Index distribution mechanism and write a query to
demonstrate how skewness can occur.
Data Analysis and Transformation
21. Write a query to calculate the percentage contribution of each product to total sales.
22. Use conditional aggregation to calculate metrics for different customer segments in a
single query.
23. Write a query to detect seasonality in sales data.
24. Perform a time-series analysis by calculating the difference in sales between consecutive
months.
25. Write a query to identify the top 5% of customers based on their purchase volume.
26. Implement cohort analysis to track customer retention over time.
27. Write a query to normalize sales data by subtracting the mean and dividing by the
standard deviation.
28. Analyze the correlation between two columns using Teradata SQL.
29. Write a query to perform a lag analysis for customer purchases.
30. Use nested subqueries to filter rows based on aggregate metrics.
Query Performance Optimization
31. Write a query and demonstrate the difference between a FULL OUTER JOIN and a LEFT
OUTER JOIN.
32. Explain the concept of Teradata partitions and write a query to analyze partitioned data.
33. Identify a poorly performing query and rewrite it to optimize performance using indexes.
34. Demonstrate the impact of skewed data on query performance and how to mitigate it.
35. Write a query to monitor query execution statistics using DBQL tables.
36. Explain the use of EXPLAIN in Teradata and provide an example of how it can be used to
optimize queries.
37. Use SAMPLE to create a random subset of data for testing purposes.
38. Write a query to identify and fix stale statistics in a Teradata table.
39. Write a query that uses volatile tables to improve performance in a multi-step
transformation process.
40. Explain how query parallelism works in Teradata and demonstrate it with an example.
Expert-Level Challenges
41. Implement a Teradata Stored Procedure to automate daily sales data aggregation.
42. Write an SQL script to dynamically generate a report for the last N days, where N is a
parameter.
43. Write a query to analyze the hash distribution of a table and identify skewed rows.
44. Design a query to simulate the behavior of a machine learning algorithm (e.g., K-means
clustering) using SQL.
45. Write a query to calculate the Gini coefficient for income inequality.
46. Develop a SQL-based ETL process to load data from a staging table into a fact table with
complex transformations.
47. Write a query to perform A/B testing analysis using Teradata SQL.
48. Implement a cross-tab query that summarizes sales data by product and month.
49. Write a query to detect outliers in a dataset using standard deviation.
50. Create a query to simulate a tree traversal algorithm for hierarchical data.
Data Modeling and Schema Design
51. Design a star schema for an e-commerce database and write queries to extract insights
from it.
52. Compare the performance of a star schema and a snowflake schema in Teradata.
53. Write a query to implement surrogate keys using IDENTITY columns in Teradata.
54. Write a query to manage slowly changing dimensions (Type 2).
55. Explain the advantages of denormalization in a data warehouse and demonstrate with an
example.
Analytical Challenges
56. Analyze customer churn trends over the last year using SQL.
57. Build a sales funnel analysis query in Teradata.
58. Write a query to calculate lifetime value (LTV) for customers.
59. Create a query to evaluate the impact of marketing campaigns on sales.
60. Perform basket analysis to identify frequently purchased item sets.
Advanced Teradata Concepts
61. Explain fallback protection in Teradata and simulate its effect on table creation.
62. Write a query to demonstrate the use of MULTISET tables.
63. Explain the differences between MULTISET and SET tables and how to handle duplicates.
64. Demonstrate the usage of NO PRIMARY INDEX (NOPI) tables and their performance
implications.
65. Write a query to explain the role of AMP in Teradata.
Complex Scenarios
66. Analyze the impact of database skew on query performance and propose solutions.
67. Write a query to combine data from multiple databases with different structures.
68. Write a query to split a large dataset into smaller chunks using Teradata utilities.
69. Implement row-level security in Teradata using views.
70. Write a query to track data lineage for a given dataset.
Big Data Integration
71. Integrate Hadoop with Teradata and demonstrate data exchange using SQL.
72. Write a query to process semi-structured data (e.g., JSON) in Teradata.
73. Perform sentiment analysis on a dataset using Teradata SQL.
Machine Learning in SQL
74. Write a query to implement linear regression calculations using SQL.
75. Use Teradata to preprocess data for a machine learning pipeline.
Expert Scenario Questions
76. Debug and optimize a Teradata query with nested subqueries and joins.
77. Develop a strategy for partitioning a large table with billions of rows.
78. Perform predictive analytics on sales data using SQL.
Real-World Applications
79. Develop a Teradata-based dashboard for operational reporting.
80. Write a query to calculate real-time metrics for an e-commerce website.
81. Write a query to forecast sales for the next quarter using SQL.
82. Implement a fraud detection algorithm in Teradata.
Case Studies
83. Write SQL scripts to analyze inventory levels and recommend reorder quantities.
84. Create an interactive reporting system using Teradata.
Miscellaneous Challenges
85. Write a query to convert data from a denormalized table to a normalized structure.
86. Explain the trade-offs between columnar and row-based storage in Teradata.
87. Implement user-defined functions (UDFs) in Teradata.
Optimization and Scalability
88. Tune a query to improve execution speed by 50%.
89. Write a query to simulate parallel execution for a large dataset.
Expert-Level Simulations
90. Create a simulation of a recommendation engine using SQL.
91. Write a query to implement a text-matching algorithm in Teradata.
Additional Questions
92-100: Design your own challenges based on real-world datasets in your domain (e.g., telecom,
retail, healthcare).