surround yourself with kind and constructive folks, enjoy the time your paths are shared, help each other, learn from others, give back, and build something together you're all proud of when you'll pass the torch
Jamal Hansen
@ham-jansen.bsky.social
Data scientist and team lead. I write about SQL, Python, and practical AI at jamalhansen.com. 5 kids, an MBA, and a blog publishing schedule that somehow hasn't fallen apart yet.
In SQL, the WITH keyword names your subqueries so each step is readable and testable on its own. Python developers already do this instinctively with named intermediate variables. jamalhansen.com/blog/ctes-ma...
CTEs: Making Your SQL Readable
WITH clauses let you name your subqueries and read top-to-bottom instead of inside-out. Transform nested spaghetti into clean steps.
jamalhansen.com
SQL subqueries = Python helper functions. Need an intermediate result? In Python you write a helper function and call it. In SQL you nest a query inside another query. This post covers the three types (scalar, list, table), correlated vs non-correlated. jamalhansen.com/blog/subquer...
Subqueries: When SQL Needs Helper Functions
Nest queries inside queries, like Python helper functions. Use them in WHERE, SELECT, or FROM to compute intermediate results.
jamalhansen.com
I built an AI persona for my blog. This week, he published his first post. His name is BartBot. He monitors RSS feeds, scores articles with a local LLM, and surfaces the ~0.7% worth reading. #LocalAI #AITools #BuildInPublic #ContentCuration #PKM #RSSFeed #BartBot
SQL has two different filters, and using the wrong one is a common mistake. WHERE filters rows before grouping. HAVING filters after. It's the difference between removing items from a list before you count them vs removing groups after you've counted. jamalhansen.com/blog/having-...
HAVING: Filtering Grouped Results
WHERE filters rows before grouping; HAVING filters after. Need "only cities with more than 10 customers"? That
jamalhansen.com
Hi everyone! It's my first #tsql2sday. Here is my post and have a great day! jamalhansen.com/blog/tsql-tu...
T-SQL Tuesday #196 - What career risks have you taken?
My first time participating in t-SQL Tuesday, answering the question, what career risks have you taken?
jamalhansen.com
Don't pull rows into Python to count them. Counter(c['city'] for c in customers) works, but sends every record over the network. SQL's GROUP BY does it on the server: SELECT city, COUNT(*) FROM customers GROUP BY city Five groups = five rows. Read more: jamalhansen.com/blog/group-b...
GROUP BY: Aggregating Your Data
GROUP BY creates buckets and counts them. It's like Python's `collections.Counter` or pandas `groupby()`. Learn COUNT, SUM, AVG, MIN, and MAX.
jamalhansen.com
SQL's WHERE filters rows before they leave the database Python: [c for c in customers if c['is_premium']] SQL: SELECT * FROM customers WHERE is_premium = true Same, but SQL filters on the server. jamalhansen.com/blog/where-f...
WHERE: Filtering Your Data
Filter rows with conditions, the SQL equivalent of list comprehension `if` clauses. Covers AND/OR, IN, BETWEEN, LIKE patterns, and NULL handling.
jamalhansen.com
Run a SQL query twice. Get different row orders. Not a bug. Databases optimize execution differently each time. If order matters, you have to be explicit with ORDER BY SQL's advantage over Python here: mixed sort directions in one line. ORDER BY date DESC, name ASC jamalhansen.com/blog/order-b...
ORDER BY: Sorting Your Results
SQL returns rows in no guaranteed order. Run the same query twice and you might get different results. ORDER BY gives you control, like Python's sorted() with key functions.
jamalhansen.com
New here (well, new-ish). I'm Jamal. Data scientist, blogger, dad of 5, MBA student. Currently on paternity leave, which means I have one hand on a baby and the other on a keyboard at all times. Looking to connect with folks in the data/Python/SQL space.
SELECT * returns everything. You probably only need two columns. But SELECT does more than pick columns. It renames with AS, computes expressions, and transforms text. It maps directly to Python list comprehensions. DISTINCT can mask problems in your query. Why? jamalhansen.com/blog/select-...
SELECT: Choosing Your Columns
SQL's SELECT is more than picking columns. Rename with AS, compute expressions, and use DISTINCT for unique values.
jamalhansen.com
I'm writing a free weekly series: SQL for Python Developers. 25 posts, 6 published so far. Every concept gets a Python comparison. Every post uses DuckDB so you can follow along with just pip install. If you write Python and avoid SQL, this is for you. 🧵
I’ve scheduled my AWS Certified Data Engineer – Associate (DEA-C01) exam for May 9. Wish me luck! - Udemy Training - www.udemy.com/course/aws-c... - 50% Discount - pages.awscloud.com/GLOBAL-other... - Certification - aws.amazon.com/certificatio... #AwsCertified #DataEngineer
Today I decided to learn Go. Just starting out and discovered that the compiler comes with dependency manager, test runner, formatter, etc. Ok, I’m curious to know more! #golang
So happy to have the opportunity to attend my first All Things Open conference this year #AllThingsOpen.