[Zope] - How to specify multiple sort columns when grouping with IN
Jim Fulton
jim@digicool.com
Thu, 21 Jan 1999 14:18:24 +0000
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.