WebSmart Code Samples
 

SQL MAX Query

Description: This program calculates the maximum quantity ordered and maximum extended amounts over all invoices using an SQL MAX query. The MAX query finds the maximum value for a certain field based on the entries selected.

select MAX(*fieldname) from *filename


Click here to view step by step instructions on how this program was created

 
Maximum Extended amount = $ 36,000.00 Maximum Quantity ordered = 900.00

Invoice Number Sequence Number Inventory Item Code Unit Price Extended Amount Quantity Ordered
111222 1 135 $ 1,030.89 $ 4,123.56 4
111222 2 224 $ 40.00 $ 36,000.00 900
111222 3 442 $ 8.00 $ 4,000.00 500
122334 1 234 $ 1,006.17 $ 2,012.34 2
122334 3 311 $ 10.00 $ 8,000.00 800
123456 2 154 $ 578.95 $ 578.95 1
135791 2 413 $ 24.00 $ 6,000.00 250
153971 1 111 $ 33.33 $ 3,333.00 100
200009 3 20 $ 7,555.65 $ 7,555.65 1
200011 4 15 $ 267.00 $ 267.00 1
200011 5 16 $ 2,583.75 $ 2,583.75 1
200012 3 34 $ 1,205.64 $ 4,822.56 4
200012 4 35 $ 384.61 $ 1,538.44 4
200013 1 21 $ 474.17 $ 4,741.70 10
200013 2 22 $ 760.52 $ 7,605.20 10
200014 2 25 $ 2,902.90 $ 2,902.90 1
200014 4 27 $ 3,349.50 $ 6,699.00 2
200015 2 27 $ 3,349.50 $ 6,699.00 2
200017 1 128 $ 3.80 $ 11.40 3
200018 1 300 $ 855.45 $ 1,710.90 2
200021 2 119 $ 77.55 $ 77.55 1
200022 1 415 $ 895.00 $ 895.00 1
200022 1 415 $ 895.00 $ 895.00 1
200022 1 415 $ 895.00 $ 895.00 1
200022 2 416 $ 550.00 $ 550.00 1
200022 2 416 $ 550.00 $ 550.00 1
200022 2 416 $ 550.00 $ 550.00 1
200022 3 119 $ 77.55 $ 77.55 1
200022 3 119 $ 77.55 $ 77.55 1
200022 3 119 $ 77.55 $ 77.55 1
200022 3 119 $ 77.55 $ 77.55 1
200024 3 119 $ 7,755.00 $ 7,755.00 1
200024 4 120 $ 7.18 $ 71.80 10
200024 6 122 $ 39.57 $ 39.57 1
200024 8 124 $ 38.37 $ 38.37 1
200029 4 115 $ 5.48 $ 43.84 8
200030 3 90 $ 39.11 $ 312.88 8
300001 4 13 $ 404.25 $ 1,617.00 4
300001 6 14 $ 1,899.59 $ 3,799.18 2
300001 7 26 $ 1,259.25 $ 2,518.50 2
300001 8 35 $ 384.61 $ 1,923.05 5
300001 9 36 $ 941.21 $ 4,706.05 5
300001 11 38 $ 2,322.90 $ 2,322.90 1
300001 12 6 $ 881.10 $ 881.10 1
300002 6 124 $ 38.37 $ 38.37 1
300002 9 131 $ 8.91 $ 71.28 8
300003 3 95 $ 14.09 $ 169.08 12
300003 4 65 $ 5.05 $ 20.20 4
300003 6 90 $ 37.15 $ 445.80 12
300003 7 66 $ 3.11 $ 24.88 8

  This example was created using WebSmart.

www.excelsystems.com