Learn SQL data types for beginners: INTEGER, DECIMAL, VARCHAR, DATE, BOOLEAN and NULL. Includes practical table design tips.
Choose a type that matches the data. Use INTEGER for counts, DECIMAL for money, VARCHAR for names, DATE for calendar dates, and NULL when a value is genuinely unknown. NULL is not zero and is not an empty string.
Example
SELECT department, COUNT(*) AS student_count
FROM students
WHERE active = 1
GROUP BY department
ORDER BY student_count DESC;Try it yourself
- Create a small table with five rows.
- Run the example and change one clause.
- Explain the result in your own words.
Back to the SQL learning path · Reference topic map · Microsoft SQL documentation
No comments:
Post a Comment
Please do not enter any spam link in the comment box.