Subject | RESTARTED [firebird-support] SELECT ... WHERE ... BETWEEN using TIMESTAMP felds |
---|---|
Author | Codebue Fabio - P-Soft |
Post date | 2009-04-20T13:25:12Z |
I have a table like this
CREATE TABLE LSV (
ART_CODICE VARCHAR(20) DEFAULT '' ,
DESCRIZIONE VARCHAR(40),
DATA_ORA TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PREZZO NUMERIC(18,6) DEFAULT 0
);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.KR.XQ', 'POWER LINE KRAUN 200MBPS BRIDGE HOMEPLUG', '25-OCT-2008
05:18:40', 65);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.ZY.66', 'ROUTER ADSL2+ ZYXEL WI-FI PRESTIGE 660HW', '25-OCT-2008
05:18:40', 79);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.HS.14', 'STAMPANTE HP DESKJET 6940', '30-MAR-2009 08:47:16', 90);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.86.HV', 'NB HP PAVILION DV7-1110EL', '20-APR-2009 13:48:09', 930);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.KR.3W', 'KRAUN KIT ROUTER ADSL2/2+ WI-FI + USBKEY', '20-APR-2009
13:53:16', 59);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.SE.23', 'HDD SEAGATE 160GB PATA 7200RPM', '20-APR-2009 13:55:11',
42.5);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.WD.86', 'HDD ESTERNO WD MY BOOK ESSENTIAL 1TB', '20-APR-2009
13:56:57', 105);
When I try to run this SQL code:
Select Art.DATA_ORA,Art.Codice,Art.Descrizione1,Lsv.Prezzo from Lsv,ART
where LSV.ART_CODICE=ART.CODICE
AND LSV.DATA_ORA between CAST('03/20/2009 00:01:00' AS TIMESTAMP) and
CAST('04/20/2009 23:59:00' AS TIMESTAMP)
ORDER BY DATA_ORA
I obtain
DATA_ORA CODICE DESCRIZIONE1
PREZZO
25/10/2008 5.18.40 CDC.KR.XQ POWER LINE KRAUN
200MBPS BRIDGE HOMEPLUG 65
25/10/2008 5.18.40 CDC.ZY.66 ROUTER ADSL2+ ZYXEL
WI-FI PRESTIGE 660HW 79
30/03/2009 8.47.16 CDC.HS.14 STAMPANTE HP DESKJET
6940 90
20/04/2009 13.48.09 CDC.86.HV NB HP PAVILION
DV7-1110EL 930
20/04/2009 13.53.16 CDC.KR.3W KRAUN KIT ROUTER
ADSL2/2+ WI-FI + USBKEY 59
20/04/2009 13.55.11 CDC.SE.23 HDD SEAGATE 160GB
PATA 7200RPM 42,5
20/04/2009 13.56.57 CDC.WD.86 HDD ESTERNO WD MY
BOOK ESSENTIAL 1TB 105
I don't have to retrieve first two lines?
Any idea?
Codebue Fabio
.--------------------------------.
P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 Chiuduno - BG
Phone: +39.035.839435
Mobile: +39.348.3515786
Fax: +39.030.5100306
.-----------------------------.
Web : www.p-soft.biz
EMail: f.codebue@...
CREATE TABLE LSV (
ART_CODICE VARCHAR(20) DEFAULT '' ,
DESCRIZIONE VARCHAR(40),
DATA_ORA TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PREZZO NUMERIC(18,6) DEFAULT 0
);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.KR.XQ', 'POWER LINE KRAUN 200MBPS BRIDGE HOMEPLUG', '25-OCT-2008
05:18:40', 65);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.ZY.66', 'ROUTER ADSL2+ ZYXEL WI-FI PRESTIGE 660HW', '25-OCT-2008
05:18:40', 79);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.HS.14', 'STAMPANTE HP DESKJET 6940', '30-MAR-2009 08:47:16', 90);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.86.HV', 'NB HP PAVILION DV7-1110EL', '20-APR-2009 13:48:09', 930);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.KR.3W', 'KRAUN KIT ROUTER ADSL2/2+ WI-FI + USBKEY', '20-APR-2009
13:53:16', 59);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.SE.23', 'HDD SEAGATE 160GB PATA 7200RPM', '20-APR-2009 13:55:11',
42.5);
INSERT INTO LSV (ART_CODICE, DESCRIZIONE1, DATA_ORA, PREZZO) VALUES
('CDC.WD.86', 'HDD ESTERNO WD MY BOOK ESSENTIAL 1TB', '20-APR-2009
13:56:57', 105);
When I try to run this SQL code:
Select Art.DATA_ORA,Art.Codice,Art.Descrizione1,Lsv.Prezzo from Lsv,ART
where LSV.ART_CODICE=ART.CODICE
AND LSV.DATA_ORA between CAST('03/20/2009 00:01:00' AS TIMESTAMP) and
CAST('04/20/2009 23:59:00' AS TIMESTAMP)
ORDER BY DATA_ORA
I obtain
DATA_ORA CODICE DESCRIZIONE1
PREZZO
25/10/2008 5.18.40 CDC.KR.XQ POWER LINE KRAUN
200MBPS BRIDGE HOMEPLUG 65
25/10/2008 5.18.40 CDC.ZY.66 ROUTER ADSL2+ ZYXEL
WI-FI PRESTIGE 660HW 79
30/03/2009 8.47.16 CDC.HS.14 STAMPANTE HP DESKJET
6940 90
20/04/2009 13.48.09 CDC.86.HV NB HP PAVILION
DV7-1110EL 930
20/04/2009 13.53.16 CDC.KR.3W KRAUN KIT ROUTER
ADSL2/2+ WI-FI + USBKEY 59
20/04/2009 13.55.11 CDC.SE.23 HDD SEAGATE 160GB
PATA 7200RPM 42,5
20/04/2009 13.56.57 CDC.WD.86 HDD ESTERNO WD MY
BOOK ESSENTIAL 1TB 105
I don't have to retrieve first two lines?
Any idea?
Codebue Fabio
.--------------------------------.
P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 Chiuduno - BG
Phone: +39.035.839435
Mobile: +39.348.3515786
Fax: +39.030.5100306
.-----------------------------.
Web : www.p-soft.biz
EMail: f.codebue@...