Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get Max and Min score
Message
 
 
To
05/04/2007 21:48:57
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01212837
Message ID:
01212848
Views:
12
Try (not tested)
SELECT * FROM mytable mt1
  WHERE testname = "math" AND score = 
  		(SELECT MAX(score) FROM mytable 
  			WHERE testname = mt1.testname and student# = mt1.student#)
UNION ALL  			
SELECT * FROM mytable mt1
  WHERE testname = "chem" AND score = 
  		(SELECT MIN(score) FROM mytable 
  			WHERE testname = mt1.testname and student# = mt1.student#)
>
>I have a table with 5 fields:
>
>mytable
>
>date  student# name testname score
>
>070401 11111 joeblow math 77
>070402 11111 joeblow math 88
>070403 11111 joeblow chem 0
>
>070401 22222 johnfit math 99
>070402 22222 johnfit math 88
>070403 22222 johnfit chem 66
>070404 22222 johnfit chem 0
>
>to have a new table
>
>mynewtable with higher score in math and lower score in chem=0 only.
>
>070402 11111 joeblow math 88
>070403 11111 joeblow chem 0
>
>
>070401 22222 johnfit math 99
>070404 22222 johnfit chem 0
>
>Please assist me with SQL coding would be appreciated very much.
>
>TK in advance.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform