How should we organize and manage data? Schemas: How should my data be logically organized? Normalization: Should my data have minimal dependency and redundancy? View...
COUNT() Returns the number of items found in a group. COUNT([ALL] expression) COUNT(DISTINCT expression) COUNT(*) Example: SELECT ...
Position Functions LEN() CHARINDEX() PATINDEX() LEN() Returns the number of characters of the provided string. Syntax: LEN...
Common mistakes when working with dates and time Inconsistent date time formats or patterns Arithmetic Operations Issues with time zones Time Zones in...
Categories of Data Types Exact numerics Approximate numerics Date and Time Character Strings Unicode Character Strings Binary Strings Other da...
Using Aggregation Functions Over Windows Ranking Functions ROW_NUMBER(): Unique, ascending integer value starting from 1. RANK(): Ascending integer value starting from 1. ...
Key Aggregation Functions Counts COUNT() COUNT_BIG() COUNT(DISTINCT) Other Aggregates SUM() ...
Dates from parts DATEFROMPARTS(year,month,day) TIMEFROMPARTS(hour, minute, second, fraction, precision) DATETIMEFROMPARTS(year, month, day, hour, minute, seconds,ms) ...
Building Dates Building a Date SELECT GETDATE() AS DateTime_LTz, GETUTCDATE() AS DateTime_UTC; SELECT SYSDATETIME() AS DateTime2_LTz,...
Grouping data in T-SQL SELECT SalesPerson, SalesYear, CurrentQuota, ModifiedDate FROM SaleGoal WHERE SalesYear = 2011 ...