21.01.2013 Views

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

exists in the left (right) table. A full outer join includes any combination. <strong>QlikView</strong> automatically makes a<br />

full outer join.<br />

Further, making joins in select statements is far more complicated than making joins in <strong>QlikView</strong>.<br />

Example:<br />

SELECT DISTINCTROW<br />

[Order Details].ProductID, [Order Details].<br />

UnitPrice, Orders.OrderID, Orders.OrderDate, Orders.CustomerID<br />

FROM Orders<br />

RIGHT JOIN [Order Details] ON Orders.OrderID = [Order Details].-<br />

OrderID;<br />

This select statement joins a table containing orders to a fictive company, with a table containing order<br />

details. It is a right outer join, meaning that all the records of OrderDetails are included, also the ones with<br />

an OrderID that does not exist in the table Orders. Orders that exist in Orders but not in OrderDetails are<br />

however not included.<br />

Join<br />

The simplest way to make a join is with the join prefix in the script, which joins the internal table with the<br />

last previously created table. The join will be an outer join, creating all possible combinations of values<br />

from the two tables.<br />

Example:<br />

load a, b, c from table1.csv;<br />

join load a, d from table2.csv;<br />

The resulting internal table has the fields a, b, c and d. The number of records differs depending on the field<br />

values of the two tables.<br />

Rules:<br />

l The names of the fields to join over must be exactly the same.<br />

l The number of fields to join over is arbitrary. Usually the tables should have one or a few fields in<br />

common. No field in common will render the cartesian product of the tables. All fields in common is<br />

also possible, but usually makes no sense.<br />

l Unless a table name of a previously loaded table is specified in the join statement the join prefix uses<br />

the last previously created table. The order of the two statements is thus not arbitrary.<br />

Keep<br />

The explicit join prefix in the <strong>QlikView</strong> script language performs a full join of the two tables. The result is<br />

one table. In many cases such joins will results in very large tables. One of the main features of <strong>QlikView</strong> is<br />

its ability to make associations between tables instead of joining them, which reduces space in memory,<br />

increases speed and gives enormous flexibility. The keep functionality has been designed to reduce the<br />

number of cases where explicit joins needs to be used.<br />

The keep prefix between two load or select statements has the effect of reducing one or both of the two<br />

tables to the intersection of table data before they are stored in <strong>QlikView</strong>. The keep prefix must always be<br />

preceded by one of the keywords inner, left or right. The selection of records from the tables is made in the<br />

same way as in a corresponding join. However, the two tables are not joined and will be stored in <strong>QlikView</strong><br />

as two separately named tables.<br />

Inner<br />

The join and keep prefixes in the <strong>QlikView</strong> script language can be preceded by the prefix inner.<br />

371

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!