Tutorial by Examples

Create a stream by selecting the elements from a stream that pass a certain condition is called filtering var newReleases = [ [ "id": 70111470, "title": "Die Hard", "boxart": "http://cdn-0.nflximg.com/images/2891/DieHard.j...
Query syntax and method syntax are semantically identical, but many people find query syntax simpler and easier to read. Let’s say we need to retrieve all even items ordered in ascending order from a collection of numbers. C#: int[] numbers = { 0, 1, 2, 3, 4, 5, 6 }; // Query syntax: IEnumerab...
A HAVING clause filters the results of a GROUP BY expression. Note: The following examples are using the Library example database. Examples: Return all authors that wrote more than one book (live example). SELECT a.Id, a.Name, COUNT(*) BooksWritten FROM BooksAuthors ba INNER JOIN Aut...
We can use 1,2,3.. to determine the type of order: SELECT * FROM DEPT ORDER BY CASE DEPARTMENT WHEN 'MARKETING' THEN 1 WHEN 'SALES' THEN 2 WHEN 'RESEARCH' THEN 3 WHEN 'INNOVATION' THEN 4 ELSE 5 END, CITY IDREGIONCITYDEPARTMENTEMPLOYEES_N...
PostgreSQL and SQLite To create a temporary table local to the session: CREATE TEMP TABLE MyTable(...); SQL Server To create a temporary table local to the session: CREATE TABLE #TempPhysical(...); To create a temporary table visible to everyone: CREATE TABLE ##TempPhysicalVisibleToEveryo...
When results need to have some logic applied 'on the fly' one can use CASE statement to implement it. SELECT CASE WHEN Col1 < 50 THEN 'under' ELSE 'over' END threshold FROM TableName also can be chained SELECT CASE WHEN Col1 < 50 THEN 'under' WHEN Col1 > 50 AND Col1 ...
Sometimes when tables are used mostly (or only) for reads, indexing does not help anymore and every little bit counts, one might use selects without LOCK to improve performance. SQL Server SELECT * FROM TableName WITH (nolock) MySQL SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;...
Sometimes one wants to capture the records that have just been updated. CREATE TABLE #TempUpdated(ID INT) Update TableName SET Col1 = 42 OUTPUT inserted.ID INTO #TempUpdated WHERE Id > 50
WITH cte AS ( SELECT ProjectID, ROW_NUMBER() OVER (PARTITION BY ProjectID ORDER BY InsertDate DESC) AS rn FROM ProjectNotes ) DELETE FROM cte WHERE rn > 1;
The Kernel#require method will load files only once (several calls to require will result in the code in that file being evaluated only once). It will search your ruby $LOAD_PATH to find the required file if the parameter is not an absolute path. Extensions like .rb, .so, .o or .dll are optional. Re...
The method Kernel#autoload registers filename to be loaded (using Kernel::require) the first time that module (which may be a String or a symbol) is accessed. autoload :MyModule, '/usr/local/lib/modules/my_module.rb' The method Kernel#autoload? returns filename to be loaded if name is registere...
When files are not available, the require family will throw a LoadError. This is an example which illustrates loading optional modules only if they exist. module TidBits @@unavailableModules = [] [ { name: 'CoreExtend', file: 'core_extend/lib/core_extend' } \ , { name: 'Fs' ...
The Kernel#load method will evaluate the code in the given file. The search path will be constructed as with require. It will re-evaluate that code on every subsequent call unlike require. There is no load_relative. load `somefile`
You can use any ruby technique to dynamically create a list of files to load. Illustration of globbing for files starting with test, loaded in alphabetical order. Dir[ "#{ __dir__ }**/test*.rb" ) ].sort.each do |source| require_relative source end
To get records having any of the given ids select * from products where id in (1,8,3) The query above is equal to select * from products where id = 1 or id = 8 or id = 3
DECLARE @DateFrom DATETIME = '2016-06-01 06:00' DECLARE @DateTo DATETIME = '2016-07-01 06:00' DECLARE @IntervalDays INT = 7 -- Transition Sequence = Rest & Relax into Day Shift into Night Shift -- RR (Rest & Relax) = 1 -- DS (Day Shift) = 2 -- NS (Night Shift) = 3 ;WITH roster AS ...
This function returns the floating-point remainder of the division of x/y. The returned value has the same sign as x. #include <math.h> /* for fmod() */ #include <stdio.h> /* for printf() */ int main(void) { double x = 10.0; double y = 5.1; double modulus = fmod(x,...
Requirements: Docker can be installed on any Linux with a kernel of at least version 3.10. Docker is supported on the following 64-bit versions of Ubuntu Linux: Ubuntu Xenial 16.04 (LTS) Ubuntu Wily 15.10 Ubuntu Trusty 14.04 (LTS) Ubuntu Precise 12.04 (LTS) Easy Installation Note: Installi...
Whenever a template is called upon, the default data context of the template is implicitly gained from the caller as in example the childTemplate gains the data context of the parentTemplate i.e caller template <template name="parentTemplate"> {{#with someHelperGettingDataForPa...
Sometimes we would like to pass into the template a template type without fixing its values. This is what template template parameters are created for. Very simple template template parameter examples: template <class T> struct Tag1 { }; template <class T> struct Tag2 { }; templ...

Page 413 of 1336