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 = $ 70,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 2 221 $ 500.00 $ 24,000.00 480
122334 3 311 $ 10.00 $ 8,000.00 800
123456 1 123 $ 15.65 $ 1,565.00 100
123456 2 154 $ 578.95 $ 578.95 1
135791 1 197 $ 12.34 $ 1,234.00 100
135791 2 413 $ 24.00 $ 6,000.00 250
153971 1 111 $ 33.33 $ 3,333.00 100
153971 2 213 $ 100.00 $ 30,000.00 300
200009 1 22 $ 800.55 $ 800.55 1
200009 3 20 $ 7,555.65 $ 7,555.65 1
200009 4 19 $ 5,169.15 $ 5,169.15 1
200009 5 250 $ 100.00 $ 50,000.00 500
200010 1 7 $ 1,575.30 $ 3,150.60 2
200010 2 6 $ 881.10 $ 3,524.40 4
200011 1 13 $ 404.25 $ 404.25 1
200011 2 130 $ 81.40 $ 81.40 1
200011 3 14 $ 1,899.59 $ 1,899.59 1
200011 4 15 $ 267.00 $ 267.00 1
200011 5 16 $ 2,583.75 $ 2,583.75 1
200011 6 17 $ 1,031.57 $ 1,031.57 1
200011 7 18 $ 2,374.05 $ 2,374.05 1
200011 8 20 $ 7,555.65 $ 7,555.65 1
200012 1 416 $ 550.00 $ 1,100.00 2
200012 1 420 $ 1,900.00 $ 1,900.00 1
200012 2 119 $ 77.55 $ 77.55 1
200012 2 33 $ 452.92 $ 2,264.60 5
200012 3 120 $ 7.56 $ 7.56 1
200012 3 34 $ 1,205.64 $ 4,822.56 4
200012 4 35 $ 384.61 $ 1,538.44 4
200012 5 36 $ 941.21 $ 1,882.42 2
200012 6 37 $ 1,223.23 $ 6,116.15 5
200012 7 333 $ 200.00 $ 62,000.00 310
200013 1 21 $ 474.17 $ 4,741.70 10
200013 2 22 $ 760.52 $ 7,605.20 10
200014 1 24 $ 2,408.25 $ 2,408.25 1
200014 1 42 $ 829.10 $ 829.10 1
200014 2 25 $ 2,902.90 $ 2,902.90 1
200014 2 43 $ 607.24 $ 2,428.96 4
200014 3 26 $ 1,259.25 $ 2,518.50 2
200014 3 44 $ 873.56 $ 4,367.80 5
200014 4 27 $ 3,349.50 $ 6,699.00 2
200014 4 45 $ 318.71 $ 1,274.84 4
200015 1 26 $ 1,259.25 $ 1,259.25 1
200015 2 27 $ 3,349.50 $ 6,699.00 2
200015 3 25 $ 2,902.90 $ 8,708.70 3
200015 4 36 $ 941.21 $ 2,823.63 3

  This example was created using WebSmart.

www.excelsystems.com