4.1. Trantypage to using the CAST
It can change the type of data from one column to make a comparison of heterogeneous data type for example between a box containing digital data and a field containing data type string ...
His syntax is CAST (AS new type column).
Example 17 SELECT CHB_ID, CHB_NUMERO, CHB_POSTE_TEL FROM T_CHAMBRE WHERE CAST(CHB_POSTE_TEL AS INTEGER) / 10 > CHB_NUMERO | CHB_ID CHB_NUMERO CHB_POSTE_TEL ------ ---------- ------------- 1 1 101 2 2 102 3 3 103 4 4 104 5 5 105 6 6 106 7 7 107 8 8 108 9 9 109 10 10 110 |
The operator of CAST allows transtyper values contained in a column.
Of course we need a type of data can be converted into another type (type compatibility), so that the answer is not marred by errors or omissions.
Example 18
SELECT ADR_VILLE, CAST(ADR_CP AS INTEGER) + 1 FROM T_ADRESSE | ADR_VILLE ADR_CP ADR_CP + 1 ------------ ------ ---------- VERSAILLES 78000 78001 MONTMAIZIN 11254 11255 PARIS 75015 75016 VERGNOLLES CEDEX452 84524 84525 MARSEILLE 13002 13003 PARIS 75012 75013 BONNEUIL CEDEX 94152 94153 PARIS 75012 75013 PARIS 75014 75015 PARIS 75017 75018 ... |
4.2. Last capitalized / Tiny
Operators LOWER UPPER and allow to capital or tiny strings in queries.
Example 19
SELECT upper(CLI_PRENOM), lower(CLI_NOM) FROM T_CLIENT | CLI_NOM CLI_PRENOM ------- ---------- ALAIN Dupont MARC Martin ALAIN Bouvier PAUL Dubois JEAN Dreyfus ALAIN Faure PAUL Lacombe EVELYNE Duhamel MARTINE Boyer MARTIN Martin ... |
NOTE: To make a search by not taking no account of the difference between upper and lower case, you must use the operator UPPER (or lower, but attention to the transformation of accents!):
Example 20
SELECT * FROM T_CLIENT where upper(CLI_PRENOM) = upper(CLI_NOM) | CLI_ID TIT_CODE CLI_NOM CLI_PRENOM CLI_ENSEIGNE ------ -------- ------- ---------- ------------------- --- 10 M. MARTIN Martin HERMAREX IMPORT_EXPORT |
NOTE: Some RDBMS can set the activation of the systematic search strings without taking into account the break. On others, the setting can be confused accented letters or not ...
4.3. Remove the white (or any other characters)
The function TRIM can remove a head or tail (or two) white or any other character specified.
TRIM ([LEADING or TRAILING or BOTH] [character] FROM column name)
LEADING: suppression in mind
TRAILING: suppression queued
BOTH: removal head and tail
In our telephone table, we want to abolish the zero lead No. order to communicate with foreigners who do not need to call this number (they must simply call 00 33 followed by the number to 9 digits).
Example 21
SELECT TEL_NUMERO, '00~33 ' || TRIM(LEADING '0' FROM TEL_NUMERO) AS TEL_INTERNATIONAL FROM T_TELEPHONE | TEL_NUMERO TEL_INTERNATIONAL -------------- ----------------- 01-45-42-56-63 00 ~ 33 1-45-42-56-63 01-44-28-52-52 00 ~ 33 1-44-28-52-52 01-44-28-52-50 00 ~ 33 1-44-28-52-50 06-11-86-78-89 00 ~ 33 6-11-86-78-89 02-41-58-89-52 00 ~ 33 2-41-58-89-52 01-51-58-52-50 00 ~ 33 1-51-58-52-50 01-54-11-43-21 00 ~ 33 1-54-11-43-21 06-55-41-42-95 00 ~ 33 6-55-41-42-95 01-48-98-92-21 00 ~ 33 1-48-98-92-21 01-44-22-56-21 00 ~ 33 1-44-22-56-21 ... |
NOTE: Some SQL servers offer different functions as LTRIM and RTRIM for a removal of white head or tail.
4.4. Extract substring
The function SUBSTRING can extract a substring from a string. It needs the first order of nature and number of characters on which it must operate.
SUBSTRING (column name FROM TO m n)
Extract the substring column name starting on m n characters.
Example 22
SELECT CLI_NOM, CLI_PRENOM, SUBSTRING(CLI_PRENOM FROM 1 FOR 1) || SUBSTRING(CLI_NOM FROM 1 FOR 1) AS INITIALES FROM T_CLIENT | CLI_NOM CLI_PRENOM INITIAL ------- ---------- --------- DUPONT Alain AD MARTIN Marc MM BOUVIER Alain AB DUBOIS Paul PD DREYFUS Jean JD FAURE Alain AF LACOMBE Paul PL DUHAMEL Evelyne ED BOYER Martine MB MARTIN Martin MM ... |
This example built the original customers from columns CLI_NOM and CLI_PRENOM_CLI.
Attention, some RDBMS using SUBSTR function.
4.5. Operator treatment dates
4.5.1. Extract a time setting a date
The operator EXTRACT can extract from a date, the day the month or year…
EXTRACT (or MONTH YEAR DAY FROM or column name)
In the table reservation on research identifying the rooms have been booked during the month of May of any year and 3 people.
Example 23
SELECT distinct CHB_ID FROM TJ_CHB_PLN_CLI WHERE EXTRACT(MONTH FROM PLN_JOUR) = 5 AND CHB_PLN_CLI_RESERVE = 1 AND CHB_PLN_CLI_NB_PERS = 3 | CHB_ID ------ 1 5 6 8 11 12 16 17 18 20 |
NOTE: it is unfortunate to note that the function EXTRACT standard SQL, often very useful, is rarely present in engines databases. Neither Access or Oracle or Sybase, and SQL Server are staffed. Only the middleware BDE Borland Inprise allows Corel to fully exploit this function with RDBMS Paradox, dBase, FoxPro, InterBase, MSSQL, Sybase, Informix, DB2, Oracle.
However it is common to find them approaching functions: Example DATEPART in SQL Server.
4.5.2. Time and current date
The current time, current date and the combined time course can be obtained using the functions CURDATE, CURRENT_TIME and CURRENT_TIMESTAMP.
Example 24
SELECT distinct CHB_ID FROM TJ_CHB_PLN_CLI WHERE (CHB_PLN_CLI_RESERVE = 1) AND PLN_JOUR BETWEEN CURRENT_DATE and CURRENT_DATE + 14 AND CHB_PLN_CLI_NB_PERS = 3attention, the result of this application varies depending on when you run! | CHB_ID ------ 1 5 6 8 11 12 16 17 18 20 |
This query returns the rooms reserved for 3 persons between the date and for the next two weeks.
Warning: Most RDBMS still do not accept this version of the standard search functions current time. Below are the functions specific to different SQL servers:
| Oracle | SYSDATE () |
| Sybase | GETDATE () |
| SQL Server | GETDATE () |
| Access | NOW () |
| MySQL | NOW () |
| Paradox (QBE) | TODAY |
4.6. Operators statistics
It is possible to make counts statistics on the columns, using the operators AVG (average), MAX (maximum), MIN (minimum), SUM (total), COUNT (number). They also call functions aggregate.
Example 25
SELECT AVG(TRF_CHB_PRIX) as MOYENNE, MAX(TRF_CHB_PRIX) as MAXI, MIN(TRF_CHB_PRIX) as MINI, SUM(TRF_CHB_PRIX) as TOTAL, COUNT(TRF_CHB_PRIX) as NOMBRE FROM TJ_TRF_CHB WHERE TRF_DATE_DEBUT = '2001-01-01' | MINI MAX AVERAGE TOTAL NUMBER -------- -------- -------- ---------- ------ 406.74 F 512.00 F 352.00 F 7 728.00 F 19 |
This application calculates the average, maximum, minimum, aggregation and the number of room rates for the date of first debut in January 2001.
It is surprising that operators statistics VARIANCE or STDDEV (standard deviation) are rarely present in the RDBMS because it is statistical functions that have great usefulness. But the standard SQL 92 has not accepted. However, they exist in Oracle. This is all the more surprising that modern techniques of DataWareHouse and in particular the DataMining use these functions in the framework of statistical calculations of hypercubes (OLAP techniques and ROLAP).
ATTENTION: we will see that the use of statistical functions requires mostly the introduction of a clause grouping, to be determined what is the target subset of aggregation for the calculations.
4.7. Other standard functions
| BIT_LENGTH | Size of a column of type or ILO ILO VARYING (number of bits) |
| CHAR_LENGTH | Size of a column of type character (number of characters) |
| OCTET_LENGTH | Size of a column of type character (number of bytes) |
| CURDATE | Date underway |
| CURRENT_TIME | Time underway |
| CURRENT_TIMESTAMP | Date and time underway |
| CONVERT | Conversion paramétrèe a string |
| POSITION | Position a string in a substring |
| TRANSLATE | Translation of a string in a format specified |
4.8. Other mathematical operators (non-standard)
Operators below can be implemented in different engines.
| ABS | absolute value |
| MOD | Modulo |
| SIGN | sign |
| SQRT | square root |
| CEIL | smallest |
| FLOOR | largest integer |
| ROUND | rounding |
| TRUNC | truncated |
| EXP | exponential |
| LN | natural logarithm |
| LOG | logarithm decimal |
| POWER | power |
| COS | cosine |
| COSH | hyperbolic cosine |
| SIN | sinus |
| SINH | sinus hyperbolic |
| TAN | tangent |
| TANH | hyperbolic tangent |
| PI | constant Pi |
Some are rarely implemented because RDBMS focus on information management, collection and processing of information rather than mathematical calculation.
Warning: the name of some of these operators may differ from RDBMS to another.
4.9. Other processors strings (non-standard)
| CONCAT | concatenation: equivalent of | | - Note: Best used | | more standard. + The column between Alpha can also often be used as a concatenation operator, prefer anyway | | |
| INITCAP | initial capital letters |
| LPAD | Completion or truncation n position left |
| LTRIM / RTRIM | removal head / tail of a chain |
| REPLACE | Replacement |
| RPAD | Completion or truncation n position on the right |
| SOUNDEX | code consonnance - Attention: phonetic often french |
| INSTR | Position a chain in a substring |
| LENGTH | length of the chain |
| TO_CHAR | digital form literal - Attention: often in English |
| ASCII | ASCII code of a character |
| CHR | character whose code ASCII is given |
| REVERSE | Reverse the order of characters at chaine |
| FLIP | Spins parties right and left of a chain compared to No. character serving as a pivot. |
Warning: the name of some of these operators may differ from RDBMS to another.
4.10. Other operators on temporal values (not standard)
| ADD_MONTH, ADD_DAY, ADD_YEAR ... | adds months, days of years at a time |
| LAST_DAY | No returns the last day of a month on a date |
| MONTH_BETWEEN | number of months between two dates |
| NEXT_DAY | date of the next day of a given name |
| TO_CHAR | date in the form literal - Attention: often in English |
| DATE_DIFF | difference between two dates |
4.11. Operators of all (non-standard)
| GREATEST | the highest values of a set |
| LEAST | the smallest of a set of values |
| DECODE | reference value located in Nth position |
5. Treatment of "values" zero
You can find additional information about the pages 115 to 120 of the book "SQL" collection "La Reference", Campus Press publisher.
NOTE: NULL is not strictly speaking a value, but the lack of value, which is why we talk marker NULL and not NULL.
The marker NULL poses a number of problems and we will raise this paragraph in a corner of the veil, that we will deal a little later in the general case of searching for occurrences of non-existence.
5.1. The null is not the empty string, or zero
NULL is not a value. It is a marker. Hence the marker NULL can never be compared has a value.
Wanted customers who did not sign.
Example 26
SELECT CLI_ID, CLI_NOM
FROM T_CLIENT
WHERE CLI_ENSEIGNE =''
CLI_ID CLI_NOM
------- --------
...
The answer must produce an empty table!
For controurner this problem requires:
is thought to record a string empty when inserting data into the table
is the WHERE clause with an operator specializing in the treatment of zero values
The problem of "null" has been well described in the book by Joe Celko "SQL advanced" published by International Thomson Publishing. Joe Celko raises the question in these terms: lack of information is it due to his ignorance or his impertinence? So why not make difference between the color of the roof of a car which is not known, and the color of the roof of a motorcycle which does not apply… Some logicians of relational algebra have gone even far in proposing different values to handle different cases, distinguishing cases very different: "null", the "unknown" and "unworkable" ...
There is therefore a real dilemma to use applications based on criteria of no value and should always be very careful to use terms that references to zero values, depending on what one wants to obtain. Especially since the NULL spread in the calculations.
Here is an excerpt from the table T_LIGNE_FACTURE
LIF_ID FAC_ID LIF_QTE LIF_REMISE_POURCENT LIF_REMISE_MONTANT LIF_MONTANT LIF_TAUX_TVA
-------- -------- --------- ------------------- ------ ----------- ------------ ------------
1 1 1.00 15.00 NULL 320.00F 18.60
2 3 1.00 F 50.00 NULL 250.00 F 18.60
3 3 1.00 F 50.00 NULL 320.00 F 18.60
4 3 1.00 F 50.00 NULL 240.00 F 18.60
5 5 1.00 NULL NULL 320.00 F 18.60
6 5 1.00 NULL NULL 220.00 F 18.60
7 7 1.00 NULL NULL 220.00 F 18.60
8 7 1.00 NULL NULL 250.00 F 18.60
9 7 1.00 NULL NULL 320.00 F 18.60
10 7 1.00 NULL NULL 270.00 F 18.60
...
We want to calculate the total cost of each line of this table, for an invoice.
The request for FAC_ID = 3 is as follows:
Example 27
SELECT FAC_ID, sum
(LIF_QTE * (LIF_MONTANT - LIF_REMISE_MONTANT) * (1 - LIF_REMISE_POURCENT / 100))
AS
TOTAL_FAC, sum
((LIF_QTE * (LIF_MONTANT - LIF_REMISE_MONTANT) *
(1 - LIF_REMISE_POURCENT / 100)) * (LIF_TAUX_TVA / (100 + LIF_TAUX_TVA)))
AS
TOTAL_TAXES
FROM T_LIGNE_FACTURE
WHERE FAC_ID = 3 GROUP BY FAC_ID
FAC_ID TOTAL_FAC TOTAL_TAXES
------ --------- -----------
3 NULL NULL
It is observed that for lines that do not have values filled in columns LIF_REMISE_POURCENT, LIF_REMISE_MONTANT, the calculation results in the value "null", which translates to display ... nothing!
NOTE: In general, to get out of this bad no one can, when creating the database, require all fields of digital type (real or whole) not to accept the zero value and take the default zero ...
Warning: the arithmetic of zero is pretty special ... Remember always that NULL spread. This is true for digital dates but also for strings. Thus SQL draws a distinction between a string and an empty field not available. In the case of the concatenation of a NULL column and a column properly informed, the return value is NULL!
5.2. Operators treatment markers NULL
The standard SQL 2 (1992) specifies a comparison and various operators on markers NULL:
IS NULL / IS NOT NULL: tests if the column is empty or not empty.
COALESCE () which seeks the first non-empty value in a set
NULLIF NULLifie a column based on a given value
COALESCE (value1, value2 [, value3] ...)NULLIF (nom_de_colonne, value) expression IS [NOT] NULL
NOTE: ISNULL (one word) is another function of connection that we sometimes encounter (reference value if the value is zero). In the same vein, or NVL VALUE are expressions COALESCE equivalent to that found on some RDBMS.
The previous query is expressed, using the operator ISNULL:
Example 28
SELECT FAC_ID,sum
(LIF_QTE * (LIF_MONTANT - ISNULL (LIF_REMISE_MONTANT, 0)) *
(1 - ISNULL (LIF_REMISE_POURCENT, 0) / 100))
AS
TOTAL_FAC, sum
((LIF_QTE * (LIF_MONTANT - ISNULL (LIF_REMISE_MONTANT, 0)) *
(1 - ISNULL (LIF_REMISE_POURCENT, 0) / 100)) * (LIF_TAUX_TVA / (100 + LIF_TAUX_TVA)))
AS
TOTAL_TAXES
FROM T_LIGNE_FACTURE
WHERE FAC_ID = 3 GROUP BY FAC_ID
FAC_ID TOTAL_FAC TOTAL_TAXES
------ --------- -----------
3 810.0 127.03
NOTE: As a general rule, when it deals with columns containing monetary values or digital, it is good to ensure that the column is mandatory and that by default it is filled to zero.
Otherwise, it will make a systematic use of functions NULLIF or COALESCE in all calculations and it will put the performance of execution!
6. Denial of values
It is NOT operator that carries out the negation of values and reverses the logical value of a predicate.
The operator may NOT be combined with most operators comparison. But it becomes very interesting lorqu'il is combined with the operators IN BETWEEN, and LIKE NULL
Wanted by example all rooms to receive at least 3 people and does not figure 4 (figure of death in Japan) or rooms bearing the No. 7 and 13 for a client particularly superstitious ...
Example 29
SELECT CHB_ID, CHB_NUMERO,
CHB_COUCHAGE FROM T_CHAMBRE
WHERE
NOT (CAST (CHB_NUMERO AS VARCHAR (10)) LIKE '% 4%')
CHB_NUMERO AND NOT IN ('7 ','13')
AND
CHB_COUCHAGE> = 3
CHB_ID CHB_NUMERO CHB_COUCHAGE
----------- ---------- ------------
1 1 3
5 5 3
6 6 5
8 8 3
11 11 3
12 12 3
15 16 3
16 17 5
17 18 3
19 20 3
We will see that NOT IN is particularly valuable in nested queries, ie requees multitables.
We now want the names of customers who do not start with 'OF':
Example 30
SELECT CLI_NOM
FROM T_CLIENT
WHERE CLI_NOM NOT LIKE '% OF'
--------------------------------
MARTIN
BOUVIER
DREYFUS
FAURE
LACOMBE
BOYER
MARTIN
PAUL
PHILIPPE
PIERRELAYE
...
7. The turnout in the SQL
You can find additional information about the 120 to 123 pages of the book "SQL" collection "La Reference", Campus Press publisher.
SQL has a connection to how FIs and other structures test procedural languages.
But it should not use that wisely, that is to say as little time as possible, many cases ouvant be treated either by the COALESCE either by queries with operations ensemblistes type UNION. Indeed performance deteriorate very quickly when using CASE because of the impossibility of effcetuer treatment "packages".
The structure of SQL CASE includes two different syntaxes. The CASE for connection to the values of expression and CASE widespread.
7.1. CASE on expression
In this case, the syntax is as follows:
CASE expression value1
WHEN THEN expression1
[value2 WHEN THEN expression2] ...
[ELSE expression_defaut]
END
Example 31
SELECT CHB_NUMERO,
CASE
WHEN CHB_ETAGE 'DRC' 0
THEN WHEN'1 st 'THEN WHEN 1 e'2' THEN 2 END
AS FLOOR, CHB_COUCHAGE BY ORDER
FROM T_CHAMBRE FLOOR, CHB_COUCHAGE
CHB_NUMERO FLOOR CHB_COUCHAGE
---------- ----------- ------------
2 0 2
3 0 2
4 0 2
1 0 3
7 1 2
9 1 2
10 1 2
5 1 3
8 1 3
11 1 3
12 1 3
6 1 5
14 2 2
15 2 2
19 2 2
21 2 2
16 2 3
18 2 3
20 2 3
17 2 5
7.2. CASE widespread
The expression disappears in favour of different predicates.
Condition1
CASE
WHEN THEN expression1
[condition2 WHEN THEN expression2] ...
[ELSE expression_defaut]
END
Example 32
SELECT CHB_NUMERO,
CASE
WHEN CHB_ETAGE = 'DRC' 0
THEN WHEN CHB_ETAGE ='1 st '
THEN WHEN 1 = CHB_ETAGE e'2' THEN 2 END
AS
FLOOR, CHB_COUCHAGE BY ORDER
FROM T_CHAMBRE FLOOR, CHB_COUCHAGE
CHB_NUMERO FLOOR CHB_COUCHAGE
---------- ----------- ------------
2 0 2
3 0 2
4 0 2
1 0 3
7 1 2
9 1 2
10 1 2
5 1 3
8 1 3
11 1 3
12 1 3
6 1 5
14 2 2
15 2 2
19 2 2
21 2 2
16 2 3
18 2 3
20 2 3
17 2 5
Who gives the same result!
ATTENTION: all RDBMS do not support these two syntaxes.
NOTE: in both cases it is possible to replace the IF a procedural language:
Condition1 CASE WHEN THEN
expression1 [ELSE expression_defaut]
END
CASE expression value1 WHEN THEN
expression1 [ELSE expression_défaut]
END
8. The manufacturer lines valued (ROW VALUE CONSTRUCTOR)
We are in front of a little-known element of SQL because rarely implemented. Pay tribute to Oracle because it is one of the few RDBMS to implement. This construction can take advantage of embarrassment for many cases drastically simplifying your queries.
The idea is that different columns to match different criteria compared with the same comparison operator can be evaluated simultaneously.
It is easier to understand this concept with an example.
One user created a table T_EVENEMENT in which he has four columns indicating the hour, minute, the second occurrence of the event and the nature of the event:
CREATE table T_EVENEMENT
(EVT_HEURE int NOT NULL, EVT_MINUTE smallint NULL,
NULL EVT_SECONDE smallint, EVT_EVENEMENT varchar (64) NOT
NULL CONSTRAINT CKC_EVT_HEURE CHECK (EVT_HEURE> = 0),
CONSTRAINT CKC_EVT_MINUTE CHECK (EVT_MINUTE BETWEEN 59 AND 0),
CONSTRAINT CKC_EVT_SECONDE CHECK ( EVT_SECONDE BETWEEN 59 AND 0))
INSERT INTO T_EVENEMENT VALUES (3, 12, 25, 'Surge')
INSERT INTO T_EVENEMENT VALUES (3, 2, 48, 'Overheating')
INSERT INTO T_EVENEMENT VALUES (3, 15, 0, 'Stop')
INSERT INTO T_EVENEMENT VALUES ( 4, 0, 0, 'Fire')
INSERT INTO T_EVENEMENT VALUES (2, 58, 59, 'Start')
INSERT INTO T_EVENEMENT VALUES (4, 22, 33, 'Explosion')
EVT_HEURE EVT_MINUTE EVT_SECONDE EVT_EVENEMENT
----------- ----------- ---------- --------------
2 58 59 Start
3 2 48 Overheating
3 12 25 Surge
3 15 0 Judgement
4 0 0 Fire
Explosion 4 22 33
The question is: what are the events after 3h 10?
Example 33: intuitively, we have to write the following query:
SELECT *
FROM T_EVENEMENT
WHERE EVT_HEURE> 3
AND
EVT_MINUTE> 10
EVT_HEURE EVT_MINUTE EVT_SECONDE EVT_EVENEMENT
----------- ----------- ---------- --------------
Explosion 4 22 33
But she forgets knowingly three events that occurred before 3:10! How is this possible?
In fact the event which occurred at 4 am 0 is not taken into account because of the first line of the WHERE clause!
EVT_HEURE> 3
AND
EVT_MINUTE> 10
simply because 0 minute is much less than 10 minutes ...
But 4h 0 is far greater than 3h 10 ... we must remove the part AND EVT_MINUTE> 10 of the WHERE clause
The correct construction is:
Example 34
SELECT *
FROM T_EVENEMENT
WHERE EVT_HEURE> 3 OR EVT_HEURE = 3
ANDEVT_MINUTE> 10
EVT_HEURE EVT_MINUTE EVT_SECONDE EVT_EVENEMENT
----------- ---------- ----------- -------------
3 12 25 Surge
3 15 0 Judgement
4 0 0 Fire
Explosion 4 22 33
Hence the idea to implement a construction able to comprehensively assess such an operation. This construction is the ROW VALUE CONSTRUCTOR I translated by manufacturer lines valued ...
With this tool, the previous query expressed more simply:
Example 35
SELECT *
FROM
WHERE T_EVENEMENT
(EVT_HEURE, EVT_MINUTE)> (3, 10)
EVT_HEURE EVT_MINUTE EVT_SECONDE EVT_EVENEMENT
----------- ---------- ----------- -------------
3 12 25 Surge
3 15 0 Judgement
4 0 0 Fire
Explosion 4 22 33
The syntax of such an expression using a ROW VALUE CONSTRUCTOR is:
(<constructeur Lines valuees>) <comparateur> (<constructeur lines valuees>)
The manufacturer lines can be valued: a list of columns, a list of values, a list that combines columns and values or even a sub Text:
(column1, column2, column3)
(column1, value1, value2, column2)
(value1, value2)
SELECT *
FROM Matable provided they do return a single line
etc. ...
The equivalent between this building and that not using the ROW VALUE CONSTRUCTOR, can be developed as follows.
Suppose that the first lines valued includes columns of tables from 1 to n and that the second line manufacturer valued contains values from 1 to n, ie:
(column1, column2 ... colonneN) <comparateur> (value1, value2 ... valeurN)
then this comparison is equivalent to:
column1 <comparateur> value1
OR
column1 = value1
AND column2 <comparateur> value2
OR
column1 = value1
AND column2 = value2
AND column3 <comparateur> value3 ...
OR
column1 = value1
AND column2 = value2
AND
...
AND colonneN <comparateur> valeurN
Also based on our game tests, here is an example more complete: all seek the events after 3h12'30 ":
Example 36
SELECT *
FROM
WHERE T_EVENEMENT
(EVT_HEURE, EVT_MINUTE, EVT_SECONDE)> (3, 12, 30)
EVT_HEURE EVT_MINUTE EVT_SECONDE EVT_EVENEMENT
----------- ---------- ----------- -------------
3 15 0 Judgement
4 0 0 Fire
Explosion 4 22 33
Example 37: and its construction logically equivalent:
SELECT *
FROM T_EVENEMENT
WHERE EVT_HEURE> 3
OR
EVT_HEURE = 3
AND
EVT_MINUTE> 12
OR
EVT_HEURE = 3
AND
EVT_MINUTE = 12
AND
EVT_SECONDE> 30
EVT_HEURE EVT_MINUTE EVT_SECONDE EVT_EVENEMENT
----------- ---------- ----------- -------------
3 15 0 Judgement
4 0 0 Fire
Explosion 4 22 33
In fact, the ROW VALUE CONSTRUCTOR acts, in research, just as if we viewed the data so fractal
The treaty is more coarse, then s'interrese a few more fine once the coarse fixed, and so forth depending on the level fractal that it was fixed.
NOTE: The use of ROW VALUE CONSTRUCTOR with a standard of comparison equality sometimes surprising results that can defy logic. We must be wary of a systematic recourse to such a construction.
Example 38: What are the events that occurred in 3 hours 12 (using the ROW VALUE CONSTRUCTOR)
SELECT *
FROM
WHERE T_EVENEMENT
(EVT_HEURE, EVT_MINUTE, EVT_SECONDE) = (3, 12)
EVT_HEURE EVT_MINUTE EVT_SECONDE EVT_EVENEMENT
----------- ---------- ----------- ---------------
3 12 25 Surge
3 2 48 Overheating
3 15 0 Judgement
This offer may interest it must be said!
The construction equivalent logic being:
Example 39
SELECT *
FROM T_EVENEMENT
WHERE EVT_HEURE = 3
OR
EVT_HEURE = 3
AND EVT_MINUTE = 12
EVT_HEURE EVT_MINUTE EVT_SECONDE EVT_EVENEMENT
----------- ---------- ----------- ---------------
3 12 25 Surge
3 2 48 Overheating
3 15 0 Judgement
Finally, note that the ROW VALUE CONSTRUCTOR has a huge interest, that allow the insertion multiple (several lines of data) in the same order INSERT!
Example 40: integration with multiple ROW VALUE CONSTRUCTOR
INSERT INTO T_EVENEMENT
(EVT_HEURE, EVT_MINUTE, EVT_SECONDE, EVT_EVENEMENT
VALUES ((4, 37, 21, 'Catastrophe'), (4, 44, 18, 'Cataclisme'), (5, 21, 1, 'Destruction final planet earth' ))
ATTENTION: only ORACLE RDBMS and a few more experimental than professionals (OCELOT for example) use such a technique!
09. Conclusion
Curiously Paradox has not implemented operators recovery time common values as they exist in QBE! It is easy to move from the date or the current time as a parameter of the request, but still ...
Regarding MS Access, one can not but be struck by the fact that most basic functions of the complaints are incompatible with the standard. For example, the LIKE wild different uses: * replaces%? replaces _. This forces to use a syntax owner who makes the portability of applications very difficult one RDBMS to another. But would this not an appropriate tactic? Another drawback it can not treat BETWEEN NOT!
More curious most RDBMS does not concatenation operator | |!
In Sybase SQL Server as the function modulo expressed as a '%' or huge possibility of confusion between wildcards, like, as the calculation of percentage ... When a release on this subject?
The RDBMS nearest the standard is that of Sybase, followed by SQL Server. The most complete game by its function is probably Oracle.