473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Columns with date

I have made a MySql database that records values every day from some
experiments. The database have x columns across. One with the name of
the experiment and the rest with the values. For example:

Experiment z21092004 z22092004 z23092004 z24092004 ++
dlk322 2 2 3 7
der42441 5 53 3 5

and so forth.

The z21092004 derives from 21 September 2004, with values going back a
few months. Now I need the data from the database and have created a
html/Python solution where one type in the experiment and gets out the
value of the first day. However, I would like to get out the values
from a range of dates. For example, select August 4 and September 2,
and then get out the sum of the values from that period of time.
However, I would not like to type "select sum from z21092004 and
z22092004 and ...." That would be hopeless especially since one might
want out the values from the span of for example 6 months. This seems
very hard when the database is organised as it is. Is there some way to
for example create a second name for each column? So that z21092004
also responded to eg 1, z22092004 to 2 and so forth. And then some way
to get the sum of column 45-68 or so forth? Or is there some better way
to organize the data?

Thanks in advance

Jul 20 '05 #1
1 1289
Tore Voldbekk wrote:
I have made a MySql database that records values every day from some
experiments. The database have x columns across. One with the name of
the experiment and the rest with the values. ... is there some better way to organize the data?


Yes, I would create a second table with rows corresponding to the daily
values, instead of columns. For instance:

create table experiment (
experiment_id integer not null auto_increment,
experiment_name varchar(20) not null
);

and a daily value table:

create table experiment_value (
experiment_id integer not null,
experiment_date date not null,
experiment_value integer not null
);

Then you can easily get a sum of a range of dates like so:

select x.experiment_name, sum(v.experiment_value)
from experiment x inner join experiment_value v
on x.experiment_id = v.experiment_id
where v.experiment_date between '2004-08-04' and '2004-09-02';

Regards,
Bill K.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tom Urbanowicz | last post by:
I have a table with 100+ columns, for which I'm trying to retrieve only 1 specific record. For this single record, I do not know which of the columns are NULL, and which are populated. I would...
2
by: Fabio | last post by:
Hello, is there any quite easy solution for the problem of transposing the rows into the columns? I have the following table with some data in it: dealer date 09.00 10.00 11.00 ...
5
by: Jagdip Singh Ajimal | last post by:
I have 6 columns, all with dates within them, i.e. Proposed Start Date 1 Proposed Start Date 2 Proposed Start Date 3 Proposed Finish Date 1 Proposed Finish Date 2 Proposed Finish Date 3 ...
1
by: J.B | last post by:
I have a datagrid that will display different datasets, (it runs different sprocs based on a value in the querystring) but it will always return 6 columns. The 5th and 6th columns are always Date...
1
by: Jennifer | last post by:
I have a datagrid where I am trying to align some columns to the center. The rest should be aligned to the right. When I try the code below I get an error message saying that the index is out of...
3
by: laredotornado | last post by:
Hi, I have two columns, both MySQL 4 DATETIME types ... TABLE1.depart_day TABLE2.depart_day and both are indexed. The problem is, all of TABLE1's dates have a time of midnight (e.g....
1
by: captainphoenix | last post by:
all in vb2005 I have three arrays: one 2d array, two 1d arrays. I need to output them into a listbox and align them to columns, which I know how to do using string.format(blahblahblah). However, in...
1
by: jglabas | last post by:
For a report, I am using a query as my record source. The query produces 5 columns by 3272 records. The data in columns 1 & 2 (“Objective” and “Rating”) repeats every 409 records The data for...
1
by: WarcraftNoob | last post by:
This is what I have right now, SELECT Project, S_on, P_on, H_on, A_on, I_on, 1_on, 2_on, 3_on, 4_on, Z_on, D_on, T_on, K_on, F_on, J_on, FINAL_on From DTable WHERE Class='XXX' AND Project...
3
by: nagmvs | last post by:
Hi to all I have one table with 6 columns and 20 rows.I want to sort each and every column when i click the column name in the table. for sorting i create one more page.when i click the column...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.