Forum Moderators: phranque

Message Too Old, No Replies

SQL code question?

         

th1chsn

7:54 pm on Sep 22, 2003 (gmt 0)

10+ Year Member



Hello, can anyone here help me with putting together some SQL code? I am trying to zero fill values where no data is showing up.

For example. In a table I have 4 people Mary, Jane, Mark, Sue and I have 3 cars Corvette, Honda, Mustang and finally how many miles they travel to and from work in that car.

I want to do a run that shows me the persons name, the car Name, and then miles travelled with that car. But if they don't have that car and/or didn't travel any miles in it I want the results to show a '0' in the miles travelled instead of just not including that record.

So each person will have a record for each car regardless of whether or not they have the car or travelled in it.

Thanks in advance.

txbakers

9:38 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if you use the "sum" function in your SQL statement it will return a 0 if no data.

If you don't want to do that, you can check for the value in your code, and "if null" assign a variable to 0.