Difference between pages "SQLZOO:SELECT basics" and "+(dates)/de"

From SQLZOO
(Difference between pages)
Jump to: navigation, search
(Introducing the BBC Table of Countries)
 
 
Line 1: Line 1:
==Introducing the BBC Table of Countries==
+
[[Category:Deutsch]]
This tutorial introduces SQL as a  query language. We will be using the SELECT command on the table bbc:
+
<table align='right' border='1'>
<table style='' border='1'><tr>
+
<caption>Kompatibilität</caption>
<th>name</th>
+
<tr><th colspan='3'>d + i</th></tr>
<th>region</th>
+
<tr><td align='center'>'''DBMS'''</td><td align='center'>'''OK'''</td><td align='center'>'''Alternative'''</td></tr>
<th>area</th>
+
<tr><td align='left'>Ingres</td><td>Nein</td><td>whn + date('7 day')</td></tr>
<th>population</th>
+
<tr><td align='left'>MySQL</td><td>Ja</td><td></td></tr>
<th>gdp</th>
+
<tr><td align='left'>Oracle</td><td>Ja</td><td></td></tr>
</tr>
+
<tr><td align='left'>PostgreSQL</td><td>Nein</td><td>[[%2B_INTERVAL/de |d+ INTERVAL 'i DAY']]</td></tr>
<tr>
+
<tr><td align='left'>SQL Server</td><td>Ja</td><td></td></tr>
<td>Afghanistan</td>
+
<td>South Asia</td>
+
<td align='right'>652225</td>
+
<td align='right'>26000000</td>
+
<td></td>
+
</tr>
+
<tr>
+
<td>Albania</td>
+
<td>Europe</td>
+
<td align='right'>28728</td>
+
<td align='right'>3200000</td>
+
<td align='right'>6656000000</td>
+
</tr>
+
<tr>
+
<td>Algeria</td>
+
<td>Middle East</td>
+
<td align='right'>2400000</td>
+
<td align='right'>32900000</td>
+
<td align='right'>75012000000</td>
+
</tr>
+
<tr>
+
<td>Andorra</td>
+
<td>Europe</td>
+
<td align='right'>468</td>
+
<td align='right'>64000</td>
+
<td></td>
+
</tr>
+
<tr>
+
<td colspan='5'>...</td>
+
</tr>
+
 
</table>
 
</table>
  
<div class='qu'>
+
<h1>+ (dates)</h1>
The example shows the population of 'France'.
+
<p>d + i liefert ein Datum, das i Tage nach dem Datum d liegt.</p>
Strings should be in 'single quotes';
+
<pre style='width:80ex'>
 
+
DATE '2006-05-20' + 7  -> DATE '2006-05-27' 
<p class='imper'>Show the population of Germany</p>
+
</pre>
 
+
<div class=params>schema:gisq</div>
 +
<div class='ht'>
 +
Im Beispiel wird ein Datum 7 Tage nach dem Datumswert in <code>whn</code> ermittelt.
 +
<source lang='sql' class='def e-ingres'>
 +
SELECT whn, whn + DATE('7 day')
 +
  FROM eclipse
 +
</source>
 +
<source lang='sql' class='def e-postgres'>
 +
SELECT whn, whn+INTERVAL 7 DAY
 +
  FROM eclipse
 +
</source>
 +
<source lang='sql' class='def e-oracle'>
 +
SELECT whn, whn+7
 +
  FROM gisq.eclipse
 +
</source>
 
<source lang='sql' class='def'>
 
<source lang='sql' class='def'>
SELECT population FROM bbc
+
SELECT whn, whn+7
   WHERE name = 'France'
+
   FROM eclipse
</source>
+
 
+
<source lang='sql' class='ans'>
+
SELECT population FROM bbc
+
  WHERE name = 'Germany'
+
 
</source>
 
</source>
 
</div>
 
</div>
  
<div class='qu'>
+
<p>Siehe auch</p>
<div>This query shows the population density <code>population/area</code>
+
<ul>
for each country where the area is over 5,000,000 km<sup>2</sup>.</div>
+
  <li>[[EXTRACT/de | Funktion EXTRACT]]</li>
<div class='imper'>Show the per capita gdp: <code>gdp/population</code>
+
  <li>[[%2B_INTERVAL/de |Funktion + INTERVAL]]</li>
for each country where the area is over 5,000,000 km<sup>2</sup></div>
+
</ul>
  
<source lang='sql' class='def'>
+
{{Languages}}
SELECT name, population/area FROM bbc
+
  WHERE area > 5000000
+
</source>
+
 
+
<source lang='sql' class='ans'>
+
SELECT name, gdp/population FROM bbc
+
  WHERE area > 5000000
+
</source>
+
</div>
+

Latest revision as of 17:18, 21 October 2012

Kompatibilität
d + i
DBMSOKAlternative
IngresNeinwhn + date('7 day')
MySQLJa
OracleJa
PostgreSQLNeind+ INTERVAL 'i DAY'
SQL ServerJa

+ (dates)

d + i liefert ein Datum, das i Tage nach dem Datum d liegt.

 DATE '2006-05-20' + 7  -> DATE '2006-05-27'  
schema:gisq

Im Beispiel wird ein Datum 7 Tage nach dem Datumswert in whn ermittelt.

SELECT whn, whn + DATE('7 day')
  FROM eclipse
SELECT whn, whn+INTERVAL 7 DAY
  FROM eclipse
SELECT whn, whn+7 
  FROM gisq.eclipse
SELECT whn, whn+7 
  FROM eclipse

Siehe auch

Sprache: English  • Deutsch
Personal tools

Variants
Actions
Reference
Toolbox
Google AdSense