× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



FWiW:

The claim was made that the SELECT query would give "subtotals by SSLMNV _followed by_ a grand total" which clearly implied a perceived ordering; i.e. something _followed by_ something. My statement that "without an explicit request to ORDER BY, there is nothing for sure to be _followed by_ anything" was an attempt to imply that any perceived ordering was not ensured, since ordering [of a set] can not be assumed.

In reading the opening text again, I see the intent is for the SELECT query to be used in a CREATE VIEW, so an ORDER BY is not even an option. However for the alluded as desirable final results [which is shown as an apparent ordered set of rows], *that* will require an ORDER BY on SELECT FROM the VIEW, to ensure that the subtotal /level/ with its summary Total will appear where expected.

Given as expected output:
ID Product Level Total
1 A 1 2
1 A 2 6
1 A 8

To effect the above as ordered, the expression CAST(NULL AS datatype) might be a better choice than using the literal _' '_ to denote the 'grand total' row. That is because the 0x40 space character will collate before the digits as Level in an ascending sort, but the NULL value will collate after both blanks & digits.

Regards, Chuck

David FOXWELL wrote:
Thanks Brigitta, although I didn't need any sorting.

CRPence wrote:
Without an explicit request to ORDER BY, there is nothing for
>>>> sure to be /followed by/ anything, regardless of how many times
the given SELECT may *appear* to effect some perceived ordering.

David FOXWELL wrote:
What you say?

Birgitta Hauser wrote:
If you need a predefined sequence in your result set, you need to add an order by clause. <<SNIP>>


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.