I want to get a resultset of the two values (page_block_name, sequence_number), where the category is 'pages'. if there are no records in that category I want only to return the values where the category is NULL.

This seems to bring back what I want but unfortunately, it also brings back the other 'default' values when they are not wanted. I only want the default values if there are no values where the page_category matches the 'search term' of pages.

Oops, scrub the second query. I had somehow written DEFAULT when it should have been = 'default' It brings back similar resulst to the first coalesce query - ie both results but also, an extra col with the case number added.

the results from that query are as follows. why does the correct result have a case number of 0 when it should have 1 (I think).

just to clarify... when the category is 'pages', the CASE is returning 1 but with sequence number of 00. And when the page_category is 'default' it is returning 0 for the CASE. Why though, is the sequence_number showing as 0 when it is the resultset I want i.e., in the relevant resultset?

I posted a couple of queries because I didn't know which was the way to go.

my table has two bundles of data, differentiated by the page_category. I want to return those in the category 'pages' but if there are none, to return those in the 'default' category. (either/or, never a mixture of page_category).

this query seems to return everything in both categories. I need a way to stop 'default' being returned if there are 'pages' results.