IBM Business System 12 - Example

Example

Sample query from BS12 article on System R website for determining which departments are over their salary budgets:

T1 = SUMMARY(EMP, GROUP(DEPTNUM), EMPS=COUNT, SALSUM=SUM(SALARY)) T2 = JOIN(T1, DEPT) T3 = SELECT(T2, SALSUM > BUDGET)

Note the "natural join" on the common column, DEPTNUM. Although some SQL dialects support natural joins, for familiarity, the example will show only a "traditional" join. Here is the equivalent SQL for comparison:

-- (SQL Version) SELECT d.Deptnum, Count(*) as Emps, Sum(e.Salary) as Salsum, Budget FROM Emp as e JOIN Dept as d ON e.Deptnum = d.Deptnum GROUP BY d.Deptnum, Budget HAVING Sum(e.Salary) > Budget

Read more about this topic:  IBM Business System 12

Famous quotes containing the word example:

    Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.
    Marcel Proust (1871–1922)