Image 1: Example data in Excel
Else Logic is a method for filtering groups of rows on a value in some rows in the group. Using Else logic writing a query for the "the children in Johnny's class" or "things bought by customers having what she buys" becomes almost as simple as asking these questions in a natural language.
Else Logic was developed for programming languages but it is a general method that could be applied e.g. to Excel spreadsheets. Image 1 shows an example Excel dataset for demonstrating the difference between traditional selection and group selection. We will use the traditional row query:
"show the sales of apples"
And the group selection query:
"show the sales of departments selling apples"
Image 2: Traditional selection
Traditional selection is row based. In Excel you can select rows based on the values in each row, in this case the rows selling "apples".
Image 2 shows the selection. This type of selection is very common and easy to execute. Click on the data selection button on the product column and select "apples".
Image 3: Group selection
Else Logic filters whole groups of rows on the values of some of the rows in the group. This form of data selection requires a more complex interface.
In figure 3 a row is selected when its department contains a row with an "apple" product. In Excel 2007 and earlier users have to manually select the right departments; something not simple for small data sets and impossible with large data sets. An interface based on Else Logic would allow the user to expand the "apples" selection by clicking on the department button and selecting a "show all rows for the current departments" option.
Else Logic is not about filtering rows in Excel, but about making group selections in programming languages easier and as short as in natural languages. The SQL Example Page demonstrates how complex writing a group selection in SQL is and how easy it becomes with Else Logic. The XQuery Example Page shows more examples and demonstrates that Else Logic is a generic method of thinking about subquery writing that can be applied to other languages.