[sqlite] how much case...when... command?

2012-04-17 Thread YAN HONG YE
UPDATE bb SET Slevel = CASE price112 WHEN 1 THEN 1 ELSE 0 END + CASE price130 WHEN 1 THEN 1 ELSE 0 END + CASE price220 WHEN 1 THEN 1 ELSE 0 END + CASE price230 WHEN 1 THEN 1 ELSE 0 END + case... csse... ... CASE price280 WHEN 1 THEN 1 ELSE 0 END; in this command, I don't know

Re: [sqlite] how much case...when... command?

2012-04-17 Thread Kit
2012/4/17 YAN HONG YE yanhong...@mpsa.com: UPDATE bb SET Slevel =    CASE price112 WHEN 1 THEN 1 ELSE 0 END +    CASE price130 WHEN 1 THEN 1 ELSE 0 END +    CASE price220 WHEN 1 THEN 1 ELSE 0 END +    CASE price230 WHEN 1 THEN 1 ELSE 0 END + case... csse... ...    CASE price280 WHEN 1

[sqlite] How point numbers are they stored in sqlite?

2012-04-17 Thread Paxdo Presse
Hi, How point numbers are they stored in sqlite? In a field with REAL affinity: round(11.578767 / 2 , 4) is displayed 5.7894 in SQLite/Navicat :-), but 5,78939997 in the cursor of my development language when I get it to sqlite. Internally, SQLite works with 5.7894 or

Re: [sqlite] How point numbers are they stored in sqlite?

2012-04-17 Thread Richard Hipp
On Tue, Apr 17, 2012 at 5:12 AM, Paxdo Presse pa...@mac.com wrote: Hi, How point numbers are they stored in sqlite? In a field with REAL affinity: round(11.578767 / 2 , 4) is displayed 5.7894 in SQLite/Navicat :-), but 5,78939997 in the cursor of my development language when I

Re: [sqlite] How point numbers are they stored in sqlite?

2012-04-17 Thread ajm
From: Paxdo Presse pa...@mac.com To: General Discussion of SQLite Database sqlite-users@sqlite.org Date: Tue, 17 Apr 2012 11:12:45 +0200 Subject: [sqlite] How point numbers are they stored in sqlite? Hi, How point numbers are they stored in sqlite? In a field with REAL affinity:

Re: [sqlite] How point numbers are they stored in sqlite?

2012-04-17 Thread Jean-Denis MUYS
On 17 avr. 2012, at 11:35, Richard Hipp wrote: On Tue, Apr 17, 2012 at 5:12 AM, Paxdo Presse pa...@mac.commailto:pa...@mac.com wrote: Hi, How point numbers are they stored in sqlite? In a field with REAL affinity: round(11.578767 / 2 , 4) is displayed 5.7894 in SQLite/Navicat :-), but

Re: [sqlite] how much case...when... command?

2012-04-17 Thread Igor Tandetnik
YAN HONG YE yanhong...@mpsa.com wrote: UPDATE bb SET Slevel = CASE price112 WHEN 1 THEN 1 ELSE 0 END + CASE price130 WHEN 1 THEN 1 ELSE 0 END + CASE price220 WHEN 1 THEN 1 ELSE 0 END + CASE price230 WHEN 1 THEN 1 ELSE 0 END + case... csse... ... CASE price280 WHEN 1 THEN 1

Re: [sqlite] How point numbers are they stored in sqlite?

2012-04-17 Thread Paxdo Presse
ok, thank you all! Le 17 avr. 2012 à 11:35, Richard Hipp a écrit : Key point: Floating point numbers are approximations. This is an inherent property of IEEE floating point numbers, not a limitation of SQLite. If you need an exact answer, use integers. -- D. Richard Hipp

[sqlite] Slightly unexpected behaviour when comparing date and datetime

2012-04-17 Thread Mark Jones
Afternoon all, I have the following schema: CREATE TABLE day (id INTEGER PRIMARY KEY, timestamp DATETIME, value REAL); And the following sample data: INSERT INTO day VALUES (NULL, 2012-01-01, 5.0); INSERT INTO day VALUES (NULL, 2012-01-02, 6.0); INSERT INTO day VALUES (NULL, 2012-01-03, 7.0);

Re: [sqlite] Slightly unexpected behaviour when comparing date and datetime

2012-04-17 Thread Simon Slavin
On 17 Apr 2012, at 4:45pm, Mark Jones m...@jonesgroup.co.uk wrote: I have the following schema: CREATE TABLE day (id INTEGER PRIMARY KEY, timestamp DATETIME, value REAL); There is no such datatype as 'DATETIME'. You are actually storing text. See especially section 1.2, but possibly

Re: [sqlite] Slightly unexpected behaviour when comparing date and datetime

2012-04-17 Thread Nico Williams
On Tue, Apr 17, 2012 at 10:45 AM, Mark Jones m...@jonesgroup.co.uk wrote: Afternoon all, I have the following schema: CREATE TABLE day (id INTEGER PRIMARY KEY, timestamp DATETIME, value REAL); And the following sample data: INSERT INTO day VALUES (NULL, 2012-01-01, 5.0); INSERT INTO

Re: [sqlite] Slightly unexpected behaviour when comparing date and datetime

2012-04-17 Thread Mark Jones
Thanks goes out to both of you for your quick responses! For text in SQLite, delimit with single quotes, not double quotes. Double quotes are used for tricky entity names. And you probably don't want the quotes around the real numbers at all. I'll go off and re-read up on the quotes and

Re: [sqlite] Slightly unexpected behaviour when comparing date and datetime

2012-04-17 Thread Nico Williams
On Tue, Apr 17, 2012 at 11:18 AM, Mark Jones m...@jonesgroup.co.uk wrote: I think I'll spend the time going back and storing the dates as integer time (since the epoch) as Nico suggested and just use strftime to convert them as and when required. Note that you'll lose any fractional second

Re: [sqlite] Slightly unexpected behaviour when comparing date and datetime

2012-04-17 Thread Black, Michael (IS)
Store them as float or do integer and multiple by a power of 10 to get as many digits as you want. So 1.234 seconds *10^3 can be 1234 integer Michael D. Black Senior Scientist Advanced Analytics Directorate Advanced GEOINT Solutions Operating Unit Northrop Grumman Information

Re: [sqlite] Slightly unexpected behaviour when comparing date and datetime

2012-04-17 Thread Richard Hipp
On Tue, Apr 17, 2012 at 2:44 PM, Nico Williams n...@cryptonector.comwrote: On Tue, Apr 17, 2012 at 11:18 AM, Mark Jones m...@jonesgroup.co.uk wrote: I think I'll spend the time going back and storing the dates as integer time (since the epoch) as Nico suggested and just use strftime to

[sqlite] Time zones

2012-04-17 Thread jwzumwalt
Where can I find a complete list of Sqlite timezones. I Google searched without success. i.e hawaiin ?? date_default_timezone_set('America/Los_Angeles'); // pacific timezone date_default_timezone_set('America/Denver'); // mountain timezone central ?? date_default_timezone_set('America/New_York);

Re: [sqlite] Time zones

2012-04-17 Thread Black, Michael (IS)
You're talking PHP...not SQLite. SQLite doesn't know about timezones other than local and utc. So your timezones will depend on your OS. On RedHat it's in /usr/share/zoneinfo and there's tons of them. I've got 1,743 of them. Michael D. Black Senior Scientist Advanced Analytics

Re: [sqlite] Time zones

2012-04-17 Thread Igor Tandetnik
jwzumwalt jwzumw...@neatinfo.com wrote: Where can I find a complete list of Sqlite timezones. I Google searched without success. i.e hawaiin ?? date_default_timezone_set('America/Los_Angeles'); // pacific timezone date_default_timezone_set is not part of SQLite. You must be using some

Re: [sqlite] Slightly unexpected behaviour when comparing date and datetime

2012-04-17 Thread Nico Williams
On Tue, Apr 17, 2012 at 2:45 PM, Richard Hipp d...@sqlite.org wrote: On Tue, Apr 17, 2012 at 2:44 PM, Nico Williams n...@cryptonector.comwrote: Note that you'll lose any fractional second information when you do this.  On the other hand, fractional second information does not sort properly

Re: [sqlite] auto-incrementing integer in composite primary key

2012-04-17 Thread Kees Nuyt
On Mon, 16 Apr 2012 11:27:06 -0500, Mr. Puneet Kishor punk.k...@gmail.com wrote: Given CREATE TABLE t ( id INTEGER NOT NULL, created_on DATETIME DEFAULT CURRENT_TIMESTAMP PRIMARY KEY (id, created_on) ); how can I make just the 'id'

Re: [sqlite] auto-incrementing integer in composite primary key (SQLite3 Solution)

2012-04-17 Thread Kyle McKay
On April 16, 2012 09:27:06 PDT, Mr. Puneet Kishor wrote: Given CREATE TABLE t ( id INTEGER NOT NULL, created_on DATETIME DEFAULT CURRENT_TIMESTAMP PRIMARY KEY (id, created_on) ); how can I make just the 'id' column auto-increment?