Run sql script and send to mail if not empty?

Thanks again for helping me out.

I was wondering if anyone else has encountered this issue.

I have a SQL script that produces a list -however we are only interested in that list if the length is not zero

Here is the sql file named dailyBalance.sql

select * from Balance where TotalBalance <0;

Here is the shell script that calls it:

#!/bin/sh

rm -f /home/astrocloud/cron_scripts/dailyBalanceChk/dailyBalance.csv
mysql -uastrocloud -pThisIsMyPassword astrocloud_daily -B < /home/astrocloud/cron_scripts/dailyBalanceChk/dailyBalance.sql|sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g'> /home/astrocloud/cron_scripts/dailyBalanceChk/dailyBalance.csv

Of course I have my own fubar way of going about it -writing a sql count of the list into a file then reading the file and if the file says 0 then don't email else email that csv list.

I hope I've given enough information.
Any suggestions?

You could test for file existence and size > zero (man sh): test -s /home/astrocloud/cron_scripts/dailyBalanceChk/dailyBalance.csv