|
How can I correctly write this select statement to return 0 if the row count is less than 1?
(comments are locked)
|
|
I'm not 100% sure what you are after here, so bear with me. Your subselect (X) is only going to return one run, by rights, because you are calling Do you want everything other than the job, year and period you select to become 0 in your table? If so, for readability, try doing it in two queries: If you really want to do it in one query, try: (but I bet there are better ways.) Otherwise, you need to be a bit more specific about what it is you are really trying to do? Thank you jimbobmcgee! This works, but now I get my divide by zero error back. I don't suppose this could be adjusted to eliminate that error?
Apr 13 '11 at 06:37 PM
technette
This is one of many sets in a table. At the end of the stored procedure, I wrote this to eliminate the divide by zero error: SELECT * FROM (select 1 a) b left join @Totaltbl on 1 = 1
Apr 13 '11 at 06:41 PM
technette
I don't see any division in your query, so I can't help you there. The typical way to resolve divide-by-zero is to use a Best I can do without a proper example. Edit your question (for formatting, at least) and include the division query, so we can see exactly what you are trying to do.
Apr 13 '11 at 07:03 PM
jimbobmcgee
I'm marking the original as answered because the question was answered. I'm working with report viewer and have put the division in the calculations. I have to somehow work with this from there. I tried a user defined function but get errors when I try to use it.
Apr 13 '11 at 07:39 PM
technette
(comments are locked)
|

