database7 Oct 2026
i was today years old when i learnt this about psql
credit: https://www.pexels.com/photo/blue-sticky-note-with-smiley-face-drawing-35037914/
i was running some sql queries and for some reason an aggregate function i was running was returning the number 0. this felt very strange since i kept looking at the command and it looked okay. so why was i getting 0?
so i decided to try simple calculation, SELECT 20 /100. 0. so after checking online i learnt that postgresql and sqlite databases discards the fraction part and only keeps the integer division. i have written window functions and recursive ctes but to think would have made me fail an interview is plainly embarrassing.
now i know
thanks for readingback to blogs