Copy-Paste dyslexia - The AS - Aliasing shouldn't be present in the GROUP-BY clause, obviously - thanks.

[...] GROUP BY ItemA, ISNULL(ItemB,0), ISNULL(ItemC,0)


On 2017/05/02 10:06 PM, R Smith wrote:
Use a substitute for the NULL values. You will have to pick a suitable substitute that doesn't confuse the other data. In this example I just use 0 as the substitute value, you might prefer another based on the true nature of your query (strings are also allowed).

SELECT ItemA, ISNULL(ItemB,0) AS ItemB, ISNULL(ItemC,0) AS ItemC
...
GROUP BY ItemA, ISNULL(ItemB,0) AS ItemB, ISNULL(ItemC,0) AS ItemC


ISNULL will return the first non-null value of the two parameters given. COALESCE() performs a similar function and allows more parameters.


On 2017/05/02 9:54 PM, Joseph L. Casale wrote:
I have a query produced from several left joins which follows the format:

XXX ItemA NULL NULL
XXX ItemA ItemB NULL
XXX ItemA NULL ItemC

I need to group the data by all columns, column 0 is trivial, however columns 1:3 can collapse when any non null field matches. In the above case this could
collapse into a single line.

How can such a query be constructed?

Thanks,
jlc

_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to