Tutorial by Examples

Wraps returned JSON array in additional root object with specified key: SELECT top 3 object_id, name, type FROM sys.objects FOR JSON PATH, ROOT('data') Result of the query would be array of JSON objects inside the wrapper object: { "data":[ {"object_id":3,&qu...
Automatically nests values from the second table as a nested sub-array of JSON objects: SELECT top 5 o.object_id, o.name, c.column_id, c.name FROM sys.objects o JOIN sys.columns c ON o.object_id = c.object_id FOR JSON AUTO Result of the query would be array of JSON objects: [ { &...
If you need some complex JSON structure that cannot be created using FOR JSON PATH or FOR JSON AUTO, you can customize your JSON output by putting FOR JSON sub-queries as column expressions: SELECT top 5 o.object_id, o.name, (SELECT column_id, c.name FROM sys.columns c WHERE o...
Select all columns from some table (system table in this case): SELECT * FROM sys.objects Or, select just some specific columns: SELECT object_id, name, type, create_date FROM sys.objects
WHERE clause filters only those rows that satisfy some condition: SELECT * FROM sys.objects WHERE type = 'IT'
ORDER BY clause sorts rows in the returned result set by some column or expression: SELECT * FROM sys.objects ORDER BY create_date
GROUP BY clause groups rows by some value: SELECT type, count(*) as c FROM sys.objects GROUP BY type You can apply some function on each group (aggregate function) to calculate sum or count of the records in the group. typecSQ3S72IT16PK1U5
HAVING clause removes groups that do not satisfy condition: SELECT type, count(*) as c FROM sys.objects GROUP BY type HAVING count(*) < 10 typecSQ3PK1U5
TOP clause returns only first N rows in the result: SELECT TOP 10 * FROM sys.objects
OFFSET FETCH clause is more advanced version of TOP. It enables you to skip N1 rows and take next N2 rows: SELECT * FROM sys.objects ORDER BY object_id OFFSET 50 ROWS FETCH NEXT 10 ROWS ONLY You can use OFFSET without fetch to just skip first 50 rows: SELECT * FROM sys.objects ORDER BY obj...
SELECT statement can be executed without FROM clause: declare @var int = 17; SELECT @var as c1, @var + 2 as c2, 'third' as c3 In this case, one row with values/results of expressions are returned.
C11 This was a new storage specifier introduced in C11 along with multi-threading. This isn't available in earlier C standards. Denotes thread storage duration. A variable declared with _Thread_local storage specifier denotes that the object is local to that thread and its lifetime is the entire e...
This example shows a helper class that contains methods useful, when executing the queries for data. Every method here uses Java Generic's in order to be very flexible. public <T> List<T> selectElements(AbstractDao<T, ?> dao) { if (dao == null) { return null; } ...
For some reasons you may want to ignore your build variants. For example: you have 'mock' product flavour and you use it only for debug purposes, such as unit/instrumentation tests. Let's ignore mockRelease variant from our project. Open build.gradle file and write: // Remove mockRelease as it...
@Singleton @Component(modules = AppModule.class) public interface AppComponent { void inject(App app); Context provideContext(); Gson provideGson(); MainActivityComponent mainActivityComponent(ActivityModule activityModule); } @ActivityScope @Subcomponent(modules = Act...
Add the following dependencies to your application. compile 'com.facebook.stetho:stetho:1.5.0' compile 'com.facebook.stetho:stetho-okhttp3:1.5.0' In your Application class' onCreate method, call the following. Stetho.initializeWithDefaults(this); When creating your Retrofit instance, crea...
This technique details how to ensure that your .apk has been signed with your developer certificate, and leverages the fact that the certificate remains consistent and that only you have access to it. We can break this technique into 3 simple steps: Find your developer certificate signature. Em...
The following are some of the more common/useful shortcuts. These are based on the default IntelliJ shortcut map. You can switch to other common IDE shortcut maps via File -> Settings -> Keymap -> <Choose Eclipse/Visual Studio/etc from Keymaps dropdown> ActionShortcutFormat codeCTRL...
Enable Offline Work: Click File -> Settings. Search for "gradle" and click in Offline work box. Go to Compiler (in same settings dialog just below Gradle) and add --offline to Command-line Options text box. Improve Gradle Performance Add following two line of code in your gradle...
System Requirements Microsoft® Windows® 8/7/Vista/2003 (32 or 64-bit). Mac® OS X® 10.8.5 or higher, up to 10.9 (Mavericks) GNOME or KDE desktop Installation Window Download and install JDK (Java Development Kit) version 8 Download Android Studio Launch Android Studio.exe then mention J...

Page 634 of 1336