select hour(timefield) as 'f1' from table1 group by f1

Ivan Smahin ivan_smahin at paradigmasoft.com
Thu Oct 18 02:28:55 CDT 2007


Hello Joseph,

Thursday, October 18, 2007, 12:35:35 AM, you wrote:


> Well I am not familiar at all with methods.
> How do I go about
> creating and storing a method. Does the method stay permanently
> on the database? Is there some documentation on creating methods?
> Also, I am using realbasic, does that effect how I go about it?

Assume there is single table with a couple of fields:

CREATE TABLE "t1" (
        "f1" LONG ,
        "f2" DATETIME );

Add some records:

INSERT INTO "t1" ("f1", "f2") VALUES (1, '30.12.2006 00:00:00:000');
INSERT INTO "t1" ("f1", "f2") VALUES (3, '31.12.2006 23:29:29:000');
INSERT INTO "t1" ("f1", "f2") VALUES (2, '01.06.1972 00:00:00:000');
INSERT INTO "t1" ("f1", "f2") VALUES (4, '30.12.2005 00:00:00:000');
INSERT INTO "t1" ("f1", "f2") VALUES (NULL, NULL);

Now you want:
select f1 from (select hour(f2) as 'f1' from t1) group by f1

But you can create a method instead:

alter table t1 add column m1 long method('month(f2)')

And now you can:
Select m1 from t1 group by m1


-- 
Best regards,
Ivan Smahin 
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina mailing list