- How to specify multiple sort columns when grouping with IN
I'm using a ZSQL method to Select rows from a database. Depending on user input, I may need to group by "apt_use, faa_cnty, faa_city, apt_name" (in that order). I want to use things like first-APT_USE, first-FAA_CNTY, etc. My database has individual indexes on all of the above fields, but there isn't a single index on all of these fields. I've been using <!--#in AirportLookup sort=name--> To group, do I need to create a new combined key in the database, or can I specify something like sort="apt_use;faa_cnty;faa_city" etc. (it doesn't work) but something like that, or will the use of the first- tags automatically cause grouping? Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com ICQ: 14856937 We must come down from our heights, and leave our straight paths, for the byways and low places of life, if we would learn truths by strong contrasts; and in hovels, in forecastles, and among our own outcasts in foreign lands, see what has been wrought upon our fellow-creatures by accident, hardship, or vice. - Richard Henry Dana, Jr. 1836
Brad Clements wrote:
I'm using a ZSQL method to Select rows from a database.
Depending on user input, I may need to group by "apt_use, faa_cnty, faa_city, apt_name" (in that order).
I want to use things like first-APT_USE, first-FAA_CNTY, etc.
My database has individual indexes on all of the above fields, but there isn't a single index on all of these fields.
I've been using <!--#in AirportLookup sort=name-->
To group, do I need to create a new combined key in the database,
Yes, or you let SQL do the sorting for you, using "sort by".
or can I specify something like sort="apt_use;faa_cnty;faa_city" etc. (it doesn't work) but something like that,
No, sort only uses a single attribute.
or will the use of the first- tags automatically cause grouping?
No. A variation on the "combined key" idea would be to provide a method on the sql result object (using a class specified via the "Adavanced" view on an SQL method) that computed a tuple of the four fields and then sort on that. Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (540) 371-6909 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
participants (2)
-
Brad Clements -
Jim Fulton