Posted in:

Guide to Learn MS SQL

GUIDE TO LEARN MSSQLMany programmers feel or have a vision of SQL being an aggressive tool. Some feel that it is quite tough to digest while many consider it as a declarative language present online which simply behaves in a different manner when compared to the object-oriented, imperative and functional language. Certainly, it is the most functional tool.

If you are a SQL programmer or if you have met one, you could easily get to know how much interesting it is. Plus if you are a reader who

  • has worked on SQL without understanding it
  • are well aware about SQL but never have imagined how the syntax would be
  • want to share and train others about SQL and using it

Easy Steps of SQL

1) Declarative

The first and foremost thing that most developers have to keep in mind is that SQL is declarative. One simply needs declaring the type of result he or she wants to get. It does not depend upon how the system computes the given results. That is the best thing about SQL.  For example:

SELECT first name, age FROM students WHERE marks > 97

The above coding is easy to comprehend and it simply would display the given results required by the user. Irrespective of data physical location, the result will comprise following the declaration.

2) Syntax Are Not In Proper Order

Among the various kinds of confusion with regard to SQL usage, is the basic fact that the syntax elements of the SQL may not be in the proper order on how they have to be executed or run. The order is in the following manner:

FROM

WHERE

GROUP BY

HAVING

SELECT

DISTINCT

UNION

ORDER BY

Here there are three aspects to keep in mind:

  • SELECT is not the first clause; it is FROM and denotes load of data to hard drive memory.
  • SELECT gets executed after other clauses are written. It is mostly after the GROUP BY and FROM. When you are thinking about the reference stuff, then you do need to give a declaration in the given SELECT clause. It will automatically assume from the declared WHERE clause.
  • Before ORDER BY, the UNION is placed, especially in logical and lexical ordering. Most people have the assumption with regard to each of the UNION. The UNION subset can be easily ordered but as per the SQL standards and the SQL dialects, all this is false. There are certain dialects which allows for ordering the derived tables and sub queries, but there is no given guarantee with regard to such ordering as they would be retained or not.

3) SQL = Table References

As there is a difference between logical and lexical ordering, most of the beginners feel that they are tricked into the process of assuming that the column values as the first class citizens of the SQL. Frankly, they are not and the most significant aspect is table references.

The SQL standard would define the FROM clause in the following manner:

<from clause> ::= FROM <table reference> [ { <comma><table reference> }… ]

In the above procedure, there are a combined and consolidated tale references with regard to the degree, i.e. degree of A+ and the degree of B. So, if A has got four columns and the B has got five columns, the total output table will be having 9 (4+5) columns. In addition, the various records obtained in this combined table would act as a reference to the given cross products or the so called Cartesian products which are of A x B.

So, in other words, each of the records of A would be paired with each records of B. If A has about four records and B has about six records, then the combined table of reference would be about 24 (4×6). Furthermore, the given output, which in this case is the above output would be piped or fed into the given groups using the GROUP BY clause. Using this clause, it would get transformed into a brand new output.

4) Table References of SQL Can Be Quite Powerful

Table reference is nothing but a cool tool which is very much powerful. A basic example of this power is the JOIN keyword. This is not the main part of the SELECT statement and it is something which is the major part of the main table reference. Some might say that it is not apt to combine all the given comma-separated list of entities present in the table reference syntax, along with the joined table of syntax, and still you must simply do this. Now the resulting and the available table of reference would be having a degree like A1+A2+B.

Frankly, the above given four steps are some of the basic guidelines which can assist in learning the MS SQL.

Leave a Reply

Your email address will not be published. Required fields are marked *