Return NULL on a SELECT with GROUP BY when any grouped value is NULL
How do I implement this?
I've checked that all the aggregator functions for GROUP BY ignore any NULL values, so I don't know anything else to get NULL when there is one or more NULL values in some grouped set of values from a LEFT JOIN.
Please this is urgent. Any suggestion would be greatly appreciated.
It sounds like you are doing random type searches through tabular data. If this is true some computing law may dictate reality as a two step process that has to be enacted. Your options include a tiny stored procedure, or scanning the columns in the result rows.
This is what Group does. I am selecting from real data.
select count(alias1.rdate),alias1.rdate,alias1.name,alias2.cause
from
sys1.alias1,sys1.alias2
where alias1.name=alias2.name
and alias1.name="No2Bots"
group by alias1.rdate
Group hides the count, but values in a group can be aggregated.
The joins are the key. The above example is a sort of join. The count shows how many times I tested that day, where each run produces eleven records of that type. Group without a count shows which days I tested. One remark is the importance of the primary search bias. If your primary search bases are spread over two tables, then you will get nulls mixed in with your union set. This entails strict exclusion and only join, no right, or left join!
p.s. In Business NULLS on a join mostly means incomplete information.
Last edited by WyCnet; 02-22-2012 at 04:19 AM.
Reason: add join effect.
Give us your schema and your entire current query. There are lots of ways to do this but without knowing what you have we are just working in assumptions. Example the query you have above could have been written in MSSQL like
Code:
SELECT
id,
SUM(ISNULL(val, 0))
FROM
yourtable
GROUP BY
id
Bookmarks