Tutorial by Examples: cte

SELECT your_columns, COUNT(*) OVER() as Ttl_Rows FROM your_data_set idnameTtl_Rows1example52foo53bar54baz55quux5 Instead of using two queries to get a count then the line, you can use an aggregate as a window function and use the full result set as the window. This can be used as a base for fur...
Generally To use regular expression specific characters (?+| etc.) in their literal meaning they need to be escaped. In common regular expression this is done by a backslash \. However, as it has a special meaning in Java Strings, you have to use a double backslash \\. These two examples will not ...
Reflection is often used as part of software testing, such as for the runtime creation/instantiation of mock objects. It's also great for inspecting the state of an object at any given point in time. Here's an example of using Reflection in a unit test to verify a protected class member contains the...
While object property notation is usually written as myObject.property, this will only allow characters that are normally found in JavaScript variable names, which is mainly letters, numbers and underscore (_). If you need special characters, such as space, ☺, or user-provided content, this is poss...
To find a character or another string, you can use std::string::find. It returns the position of the first character of the first match. If no matches were found, the function returns std::string::npos std::string str = "Curiosity killed the cat"; auto it = str.find("cat"); ...
The STUFF() function inserts a string into another string by first deleting a specified number of characters. The following example, deletes "Svr" and replaces it with "Server". This happens by specifying the start_position and length of the replacement. SELECT STUFF('SQL Svr D...
// Java: String phrase = persons .stream() .filter(p -> p.age >= 18) .map(p -> p.name) .collect(Collectors.joining(" and ", "In Germany ", " are of legal age.")); System.out.println(phrase); // In Germany Max and Peter a...
// Java: Map<Integer, String> map = persons .stream() .collect(Collectors.toMap( p -> p.age, p -> p.name, (name1, name2) -> name1 + ";" + name2)); System.out.println(map); // {18=Max, 23=Peter;Pamela, ...
// Java (verbose): Collector<Person, StringJoiner, String> personNameCollector = Collector.of( () -> new StringJoiner(" | "), // supplier (j, p) -> j.add(p.name.toUpperCase()), // accumulator (j1, j2) -> j1.merge(j2), // c...
// Java: IntSummaryStatistics ageSummary = persons.stream() .collect(Collectors.summarizingInt(p -> p.age)); System.out.println(ageSummary); // IntSummaryStatistics{count=4, sum=76, min=12, average=19.000000, max=23} // Kotlin: // something to hold the stats... da...
It often is faster to use a generic template when first creating a new alert and only specialize the template when you need to display more information. The following template will display a subject with a numerical value, custom formatting, and description string and then a body with up to two grap...
A newline can be included in a single-string or double-quoted string. Note that backslash-newline does not result in a newline, the line break is ignored. newline1=' ' newline2=" " newline3=$'\n' empty=\ echo "Line${newline1}break" echo "Line${newline2}break" ...
In a normal string, the backslash character is the escape character, which instructs the compiler to look at the next character(s) to determine the actual character in the string. (Full list of character escapes) In verbatim strings, there are no character escapes (except for "" which is ...
This example requires the headers <algorithm>, <locale>, and <utility>. C++11 To trim a sequence or string means to remove all leading and trailing elements (or characters) matching a certain predicate. We first trim the trailing elements, because it doesn't involve moving any el...
Rails uses sqlite3 as the default database, but you can generate a new rails application with a database of your choice. Just add the -d option followed by the name of the database. $ rails new MyApp -T -d postgresql This is a (non-exhaustive) list of available database options: mysql oracle...
To get a verbose list of all devices connected to adb, write the following command in your terminal: adb devices -l Example Output List of devices attached ZX1G425DC6 device usb:336592896X product:shamu model:Nexus_6 device:shamu 013e4e127e59a868 device usb:337641472X produc...
To broaden the selections of a structured query language (SQL-SELECT) statement, wildcard characters, the percent sign (%) and the underscore (_), can be used. The _ (underscore) character can be used as a wildcard for any single character in a pattern match. Find all employees whose Fname start w...
In many cases, the Razor parser is smart enough to figure out when the @ sign is meant to be used as part of code, as opposed to being part of something like an email address. In the example below, escaping the @ sign is not necessary: <p>Reach out to us at [email protected]</p> Howev...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-widt...
Note that some syntax elements have different behavior depending on the expression. SyntaxDescription?Match the preceding character or subexpression 0 or 1 times. Also used for non-capturing groups, and named capturing groups.*Match the preceding character or subexpression 0 or more times.+Match th...

Page 2 of 14