Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Rhino9
Starting Member
3 Posts |
Posted - 2006-05-07 : 12:41:22
|
| I am attempting to write a function to Check the price of every disk and return the number of titles ont he disk which has the highest price. I do not even think that I am in the ballpark:CREATE FUNCTION highest_price ( )BEGINSELECT count(*) ASFROM DiskWHERE price = (SELECT max(price) FROM Disk);END/MusicalWork (idwork, title)Piece (idpiece, duration, iddisk, idwork)Disk (iddisk, brand, type, issuingdate, price)Execute (idpiece, idinterpreter)Interpreter (idinterpreter, name, address)Thank you in advance! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-07 : 18:01:10
|
[code]CREATE FUNCTION highest_price ( )RETURNS INTBEGINRETURN ( SELECT count(*) AS NUMTITLES FROM Disk WHERE price = (SELECT max(price) FROM Disk) )END[/code] KH |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-05-08 : 03:39:09
|
| Read about User Defined Functions(UDF) in Book Online...If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
|
|
|