HELPFUL DBA SQL
SELECT All Columns from a Table and Sort
Select Specific Columns and Limiting the Rows
Changing your Default Database
Keywords that describe you
Select TOP Rows in a Rank Order
A Sample number of rows
Getting a Sample Percentage of rows
Find Information about a Database
Find information about a Table
Using Aggregates
Performing a Join
Performing a Join using ANSI Syntax
Using Date, Time and Timestamp
Using Date Functions
Using the System Calendar
Using the System Calendar in a Query
Formatting Data
Using Rank
Using a Derived Table
Using a Subquery
Correlated Subquery
Using Substring
Basic CASE Statement
Advanced CASE Statement
Using an Access Lock in your SQL
Collect Statistics
CREATING a Volatile Table with a Primary Index
CREATING a Volatile Table that is Partitioned (PPI)
CREATING a Volatile Table that is deleted after the Query
Finding the Typical Rows per Value for specific column
Finding out how much Space you have
How much Space you have Per AMP
Finding your Space
Finding Space Skew in Tables in a Database
Finding the Number of rows per AMP for a Column
Finding Account Information
Ordered Analytics
SELECT ((firstresptime – firststeptime) HOUR(4) TO SECOND) AS runtime,TotalIOCount, AMPCPUTime, NumResultRows, querytext
FROM dbc.dbqlogtbl
WHERE USERNAME = ‘sysdba’
AND GETQUERYBANDVALUE(COALESCE(queryband,”),0, ‘TD15Test’) = ‘DBA_SPECPROMO_SQL10’
ORDER BY starttime DESC
SET QUERY_BAND = ‘TD15Test = DBA_SPECPROMO_SQL10;’ FOR SESSION;
SET QUERY_BAND = ‘BlockCompression=Y;’ FOR SESSION;