Friday, December 12, 2008

Suction Curtain Rails





MORE ON SQL: WHERE clause, HAVING, GROUP BY

Where

The select command performs the operation of selection, projection and conjunction on a relational data base. Do the operation selection is possible with the passage from one report to another report only rows that meet a certain condition, so you can play the where clause using the SQL command select.La where clause serves to implement the conditions verificabili a livello delle singole righe.Attraverso il comando select vengono attivate le interrogazioni sulle relazioni e le operazioni relazionali con l’obiettivo di ottenere nuove tabelle.
Il comando select possiede due predicati all e distinct. Con all si indica di ottenere come risultato dell’interrogazione tutte le righe che soddisfano le condizioni contenute nel comando. Se viene specificato il predicato distinct le righe duplicate nella tabella risultante vengono ridotte ad una. La tabella che contiene come risultato dell’interrogazione con select normalmente possiede un’intestazione delle colonne che riporta i nomi degli attributi, ciò si fa con la clausola as.L’operazione di proiezione, che permette di ottenere una relazione contenente solo alcuni attributi della relazione di partenza, si realizza indicando accanto alla parola select l’elenco degli attributi richiesti.Il comando select può operare su più tabelle, indicandone i nomi (separati da virgola) dopo la parola from; scrivendo poi dopo la parola where i nomi degli attributi che si corrispondono nelle due tabelle (legati tra loro dal segno = ), si realizza in pratica l’operazione di congiunzione di due tabelle secondo un attributo comune.Se si vuole conservare la tabella risultante dall’operazione, occorre aggiungere al comando select la clausola into seguita dal nome da assegnare alla nuova tabella.
Ordinamenti e raggruppamenti: order by, group by, having.

Order by
In

select command you can enter the order by clause to get the query results ordered according to the values \u200b\u200bcontained in one or more columns, including those listed next to the word select. You can sort ascending or descending order of the two types are specified respectively using the keyword ASC for ascending and desc for descending.
The order by clause is the last element of an SQL command. In the laws of the value appears at the beginning of the end sequences of increasing and decreasing sequences.

Group by using the aggregation functions you can extend the structure of the select command with the addition of the clause to join the group by a set of lines having the same value in the columns indicated: producing a result row for each grouping.
But if you use a GROUP BY clause, the attributes that appear in the select list next to the word should be included in the GROUP BY clause or be subjects of an aggregate function. Having

The select command can be extended further by having clause that he can bring the control of one or more of the conditions created groups with the group by clause.
the HAVING clause has similar characteristics to the where clause, but acts in a different way: with WHERE conditions are placed on the rows of the table, instead HAVING with condition monitoring is done on the results of the aggregate function applied to a group of rows.

0 comments:

Post a Comment