Summary and detail queries
This topic gives an example of a summary query and of a detail query based on this fictional grocery store data:
Product Category | Product ID | Product | Quantity | Cost |
---|---|---|---|---|
Dairy | 10001 | Cheese | 3 | 9 |
Dairy | 10002 | Milk | 2 | 6 |
Fruit | 20001 | Apple | 8 | 12 |
Fruit | 20003 | Pineapple | 5 | 4 |
Fruit | 20004 | Cherries | 30 | 10 |
Bakery | 30001 | Sandwich loaf | 10 | 20 |
Bakery | 30001 | Sandwich loaf | 8 | 15 |
Bakery | 30001 | Sandwich loaf | 2 | 6 |
Bakery | 30001 | Sandwich loaf | 3 | 9 |
Bakery | 30002 | Toast loaf | 20 | 25 |
Bakery | 30002 | Toast loaf | 10 | 25 |
Bakery | 30003 | Wholemeal loaf | 15 | 35 |
Bakery | 30003 | Wholemeal loaf | 10 | 25 |
Bakery | 30003 | Wholemeal loaf | 5 | 10 |
Bakery | 30004 | Cakes | 6 | 12 |
Bakery | 30004 | Cakes | 12 | 24 |
Summary query
A summary query provides a summarized listing. The result is a row which contains all output data items for each summary level. For example, a list of goods and quantities with IDs 30001 to 30003.
In this example:
- The data filter item is Product ID =30001 to 30003
- The output data items are Product and Quantity
This table shows the output:
Product | Quantity |
---|---|
Sandwich loaf | 23 |
Toast loaf | 30 |
Wholemeal loaf | 30 |
Total | 83 |
Detail query
A detail query provides a detailed listing. The results is a row for each record in the database. For example, all products that include the term 'Loaf', and their quantities.
In this example:
- The data filter item is Product =%Loaf%
- The output data items are Product and Quantity
This table shows the output:
Product | Quantity |
---|---|
Sandwich loaf | 2 |
Sandwich loaf | 3 |
Sandwich loaf | 8 |
Sandwich loaf | 10 |
Toast loaf | 10 |
Toast loaf | 20 |
Wholemeal loaf | 5 |
Wholemeal loaf | 10 |
Wholemeal loaf | 15 |