Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MIN() MAX() in SQL on multiple fields
Message
 
À
06/04/2015 16:32:00
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Web
Divers
Thread ID:
01617834
Message ID:
01617862
Vues:
43
I'm going to try this.
PROCEDURE myMin
LPARAMETERS f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, ;
            f12, f13, f14, f15, f16, f17, f18, f19, f20
LOCAL lcFld as String, lnMin as Number

lnCrazyLargeNumber = 9999999
lnMin = lnCrazyLargeNumber

FOR i = 1 TO PCOUNT()
	lcFld = "f" + ALLTRIM(STR(i))
	IF TYPE(lcFld) == "N"
		IF &lcFld < lnMin
			lnMin = &lcFld
		ENDIF 	
	ENDIF 
ENDFOR 

IF lnMin == lnCrazyLargeNumber
	RETURN .null.
ELSE
	RETURN lnMin
ENDIF 	

ENDPROC 
and then call it like this (and include cast)
SELECT *, CAST(mymin(f1, f2, f3, ...) AS N(10,4)) as mymin FROM mytable
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform