Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
SQL Directives Order of Execution
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
--Sql Server 2014 Express Edition --Batches are separated by 'go' select @@version as 'sql server version' -- Following is order in which SQL directives get executed FROM clause WHERE clause GROUP BY clause HAVING clause SELECT clause ORDER BY clause -- Examples: -- FROM --Since FROM clause executes first, it is our first opportunity to narrow down possible record set sizes. --Try to put as many of you ON rules (for joins) as possible in this area as opposed to in the WHERE clause: FROM contact c INNER JOIN display_status d ON ( c.display_status_id = d.id AND d.is_active = 1 ) -- WHERE --If we create a column in the SELECT directive: "TotalSales" SELECT Name, SUM(Sales) AS TotalSales FROM SalesDB WHERE TotalSales > 1000 --It will not be available in the WHERE clause because the SELECT clause has not even been executed at the --time the WHERE clause is being run.
View schema
edit mode
|
history
|
discussion
stackse - search stackoverflow differently