0 Replies - 1361 Views - Last Post: 28 March 2007 - 11:05 PM

#1 Trogdor   User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 627
  • Joined: 06-October 06

Returning default values

Posted 28 March 2007 - 11:05 PM

Description: It is quite simple realy. Say you have a query that returns a named field called count. (select count(*) as count from bla outer join blop where x having y group by z) lets call the peice of existing sql that returns counts. you can glue the entire thing together with another query using the UNION statement. UNION the alternative would be something like SELECT 0 AS count Then the changed query will be something like this:In complex queries involving counts it can happen that you get no resultset where you would want a 0. This is how to do it.
select count(*) as count from bla outer join blop where x having y group by z

UNION

SELECT 0 AS count



Is This A Good Question/Topic? 0
  • +

Page 1 of 1