
Malek Damiri
I’m Malek Damiri, Head of Revenue Operations, based in Atlanta. This is my notebook: short SQL notes from revenue reporting work, a few photos, and what I’m up to outside work.
Longer essays on revenue metrics and reporting live at malekdamiri.com.
Notes
- Build a date spine so empty days countGROUP BY drops the days with no rows. A date spine puts them back, and changes the average.
- Keep the latest row per key with QUALIFYTaking max() of each column mixes values from different rows. QUALIFY keeps one whole row per key.
- Check row counts before you trust a joinA join to a table with duplicate keys multiplies revenue. Two quick checks catch it.
- Find streaks with gaps and islandsSubtract a row number from a month number and consecutive months share a value. That's the whole trick.
- LAG compares to the previous row, not the previous monthWhen a month is missing, LAG silently compares to an older one. Fill the months first.
Outside work
I run, half marathons included, and hike in North Georgia when I can. I’m a football fan. At home it’s espresso, records, and Ben, my goldendoodle. More on the about page and in photos.