Hi,
I have a query that generates a table with following columns follows:
Aaa Aa1 Aa2 Aa3 Baa1 Baa2 Baa3 Ba1 Ba2 Ba3 B1 B2 B3 CCaa D
This is generated by an insert into statement. I then modify the table
to add an autoincrement primary key (to preserve row order).
What I want is to be able to loop my code, ie each 'run' produces one
table of the above format. I want another table to hold the sum of
tables. e.g.
Say I had
Cols: Item 1 / Item 2
11 1
4 10
and:
Cols: Item 1 / Item 2
19 12
14 8
I want another table to give me
Cols: Item 1 / Item 2
30 13
18 18
and when i run the code again and say the following gets produced:
Cols: Item 1 / Item 2
1 1
1 1
I want to update my summation table to reflect
Cols: Item 1 / Item 2
31 14
19 19
Any thoughts on how this can be done ?
Thanks ! 12 1870
Assuming the autonumbers are in tact and you are adding matching the
rows number by number, then:
select
table1.item1 + table2.item1 as item_1,
table1.item2 + table2.item2 as item_2
from
table1 inner join table2 on table1.PK = table2.PK
will give you the summation.
Otherwise you will need sub-queries to privide a psudo key based on
row order (sorted by your autonum) and join them on that. you may need
to look that up seperately.
i'm worried that you are creating a bunch of tablees every time you
run the code, but would you not be far better off having code that
updated the data in the existing tables? it's hard to know that you
are doing here without seeing the code you are using to produce your
tables.
If you _really_ want to make a table of the result, you can turn the
above query into a make table query quite easily from the design view
of the query editor.
On May 21, 7:57 am, "sandiptay...@g mail.com" <sandiptay...@g mail.com>
wrote:
Hi,
I have a query that generates a table with following columns follows:
Aaa Aa1 Aa2 Aa3 Baa1 Baa2 Baa3 Ba1 Ba2 Ba3 B1 B2 B3 CCaa D
This is generated by an insert into statement. I then modify the table
to add an autoincrement primary key (to preserve row order).
What I want is to be able to loop my code, ie each 'run' produces one
table of the above format. I want another table to hold the sum of
tables. e.g.
Say I had
Cols: Item 1 / Item 2
11 1
4 10
and:
Cols: Item 1 / Item 2
19 12
14 8
I want another table to give me
Cols: Item 1 / Item 2
30 13
18 18
and when i run the code again and say the following gets produced:
Cols: Item 1 / Item 2
1 1
1 1
I want to update my summation table to reflect
Cols: Item 1 / Item 2
31 14
19 19
Any thoughts on how this can be done ?
Thanks !
First tables do not have columns they have fields.
Second tables do not have rows they have recrods.
Third, autonumber will not NECESSARILY match any given 'order'.
Autonumber is NOT intended to be used as a field that has any meaning
what-so-ever- to the data within the table. It is merely a unique
numebr assigned to each record. Using increment rather than random
autonumbers does not change this at all. Just because a given record
has the value "6" in the autonumber field does NOT mean that it is the
6th record. As such it is (IMHO) always better to use random
autonumbers so asto not even give the appearance that the numbers mean
anything.
To do what I THINK you are asking you should first have ADD TWO
fields. One a field that YOU populate with unique data (such as a
item tag number, employee id, etc). The other a field with called
RunDate or something silimar that hold the date a given run was made.
Then modify yoru 'code' so that it appends data to the table on each
run rather than creating a new table each time. After that you can
run a simple summation query to get the desired output.
If you continue in the manner you are on, you will need to run
multiple queries to ensure that unmatched records are summed etc.
On May 21, 7:57 am, "sandiptay...@g mail.com" <sandiptay...@g mail.com>
wrote:
Hi,
I have a query that generates a table with following columns follows:
Aaa Aa1 Aa2 Aa3 Baa1 Baa2 Baa3 Ba1 Ba2 Ba3 B1 B2 B3 CCaa D
This is generated by an insert into statement. I then modify the table
to add an autoincrement primary key (to preserve row order).
What I want is to be able to loop my code, ie each 'run' produces one
table of the above format. I want another table to hold the sum of
tables. e.g.
Say I had
Cols: Item 1 / Item 2
11 1
4 10
and:
Cols: Item 1 / Item 2
19 12
14 8
I want another table to give me
Cols: Item 1 / Item 2
30 13
18 18
and when i run the code again and say the following gets produced:
Cols: Item 1 / Item 2
1 1
1 1
I want to update my summation table to reflect
Cols: Item 1 / Item 2
31 14
19 19
Any thoughts on how this can be done ?
Thanks !
First tables do not have columns they have fields.
Second tables do not have rows they have recrods.
Third, autonumber will not NECESSARILY match any given 'order'.
Autonumber is NOT intended to be used as a field that has any meaning
what-so-ever- to the data within the table. It is merely a unique
numebr assigned to each record. Using increment rather than random
autonumbers does not change this at all. Just because a given record
has the value "6" in the autonumber field does NOT mean that it is the
6th record. As such it is (IMHO) always better to use random
autonumbers so asto not even give the appearance that the numbers mean
anything.
To do what I THINK you are asking you should first have ADD TWO
fields. One a field that YOU populate with unique data (such as a
item tag number, employee id, etc). The other a field with called
RunDate or something silimar that hold the date a given run was made.
Then modify yoru 'code' so that it appends data to the table on each
run rather than creating a new table each time. After that you can
run a simple summation query to get the desired output.
If you continue in the manner you are on, you will need to run
multiple queries to ensure that unmatched records are summed etc.
DavidB wrote:
First tables do not have columns they have fields.
Second tables do not have rows they have recrods.
Actually these terms are fairly isolated to Access users. In the more
general SQL/Relational database world Column/Row is considered correct and
Field/Record incorrect.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
On May 21, 12:59 pm, "Rick Brandt" <rickbran...@ho tmail.comwrote:
DavidB wrote:
First tables do not have columns they have fields.
Second tables do not have rows they have recrods.
Actually these terms are fairly isolated to Access users. In the more
general SQL/Relational database world Column/Row is considered correct and
Field/Record incorrect.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
I have worked with many databases and NONE have EVER referred to
fields and records are columns and rows. It is 100% logical in the DB
world to use field and record. Those are the basic building blocks of
a database. The element of data you define is unary. It is akin to
the correct naming convention for tables being singular words rather
than plurals (eg a table that hold vendor records would be called
tVendor or tblVendor NOT tVendors or tblVendors. I'll stick with what
I have used since I have been coding.
DavidB wrote:
On May 21, 12:59 pm, "Rick Brandt" <rickbran...@ho tmail.comwrote:
>DavidB wrote:
>>First tables do not have columns they have fields.
>>Second tables do not have rows they have recrods.
Actually these terms are fairly isolated to Access users. In the more general SQL/Relational database world Column/Row is considered correct and Field/Record incorrect.
-- Rick Brandt, Microsoft Access MVP Email (as appropriate) to... RBrandt at Hunter dot com
I have worked with many databases and NONE have EVER referred to
fields and records are columns and rows. It is 100% logical in the DB
world to use field and record. Those are the basic building blocks of
a database. The element of data you define is unary. It is akin to
the correct naming convention for tables being singular words rather
than plurals (eg a table that hold vendor records would be called
tVendor or tblVendor NOT tVendors or tblVendors. I'll stick with what
I have used since I have been coding.
From IBM's web site...
Traditional File Access Term: File
SQL Term: Table
Traditional File Access Term: Record
SQL Term: Row
Traditional File Access Term: Field
SQL Term: Column
I have no problem with your preference to use Record/Field instead of
Column/Row. I pretty much use the terms interchangeably myself. I just
think telling people who use the terms Column/Row that they are incorrect is
inaccurate.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
I have worked with many databases and NONE have EVER referred to
fields and records are columns and rows. It is 100% logical in the DB
world to use field and record. Those are the basic building blocks of
a database. The element of data you define is unary. It is akin to
the correct naming convention for tables being singular words rather
than plurals (eg a table that hold vendor records would be called
tVendor or tblVendor NOT tVendors or tblVendors. I'll stick with what
I have used since I have been coding.
it doesn't really matter what you call them - but to set the record
straight, once you leave the access world, tables have columns and
rows, recordsets have records and fields. Some people actually get
quite upset when you mix this up! check out Joe Celko's SQL Server
blog... actually my old database lecturer used to talk in terms of
"tuples" - confused the life out of me!!!
Actually just searched on that term now and it brought up an
interesting table:
Informal relational term Formal relational term Non-relational
term
Table Relation File
Column Attribute Field
Row Tuple Record
so table, column and row are informal relational terms and file, field
and record are non-relational terms. and my lecturer was throwing in
old school formal terms... no wonder i was confused!
actually - a little more study on classical relational database theory
has me floored... i wish i had understood this stuff in college! a
relation is a set of tuples with attributes. this is often
_represented_ as a table. i.e. there is no actual table, because by
definition, the attributes should have no order and neither should the
tuples. and what we view as a table definition is a set of constraints
on the tuples in a relation. this is why when we interact with
relations as "tables", it is more appropriate to to refer to
"columns" and "rows". and by contrast, a recordset is a set of data
returned in ordered records with ordered fields - so "records" and
"fields" is appropriate. crazy shit!!!!!
"DavidB" <je***@yahoo.co mwrote in message
news:11******** **************@ x35g2000prf.goo glegroups.com.. .
>
I have worked with many databases and NONE have EVER referred to
fields and records are columns and rows. It is 100% logical in the DB
world to use field and record. Those are the basic building blocks of
a database. The element of data you define is unary. It is akin to
the correct naming convention for tables being singular words rather
than plurals (eg a table that hold vendor records would be called
tVendor or tblVendor NOT tVendors or tblVendors. I'll stick with what
I have used since I have been coding.
FWIW there was a time when I would have defended that stance but not since I
began working with Oracle.
Keith. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: PG |
last post by:
When deleting a row from the database, that id is now missing.
So what I'm trying to do is update in a loop (maybe an sql loop if
there is one) of all of the id numbers - sort of like renaming them.
It did partly work because all the id's were set to 22. Thats because
there was 22 rows.
Here's the code I used:
$result = mysql_query ("SELECT * FROM counter");
for($counting = 1; $row = mysql_fetch_row ($result); ++$counting)
|
by: Uwe C. Schroeder |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi.
I have the following little stored proc:
CREATE OR REPLACE FUNCTION public.ib_nextval(varchar)
RETURNS varchar AS
'DECLARE
|
by: Arash |
last post by:
hi,
I read couple of emails in the group regarding using the form to
display a message (instead of MsgBox which needs user input to be
closed). I'm not very familiar with forms, I would appreciate if
someone can add couple of codes to my code in order to display the
variable "counter" in a form.
Thanks in advance,
Arash
|
by: Uwe C. Schroeder |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
maybe my mind is stuck, but here's something strange.
This is the classic "counter" thing, where you can't / won't use sequences.
Basically I need to assemble an identifier like
|
by: news.east.cox.net |
last post by:
Hello,
I'm trying to figure out why the following code won't work for me. The
Firefox javascript console tells me that tableItemClicked is not
defined, but the function is right there in the code. Any help would be
greatly appreciated.
<script type="text/javascript">
function Initialize() //is called upon page load
{
| |
by: nanoman |
last post by:
Hello,
I've got a Nested Set structure in MySQL 4 here with
- id
- lft
- rgt
- parent_id
- root_id
I wrote some test scripts and i discovered that the Nested Set (the
|
by: marting |
last post by:
Before I throw my new expensive laptop out of the window!
I'm stuck on getting my joins right with the correct amount in a column count. After speaking with someone a few weeks back, they suggested I redesigned my database to use more tables of info. Before I had 1 table for image information, now I have 9 and it's getting very, very confusing... especially as I don't know much about joins...!
I am using ASP, MySQL, IIS and VBScript.
...
|
by: PaullyB |
last post by:
Hi There
I'm trying to insert a CSV file into SQL Database using C#. I can read the csv file and insert it into the table, however any fields with an embebbed comma are not being read correctly. How can I get around this.
Below is the code that I'm using:
protected void cmdUploadFile_Click(object sender, EventArgs e)
{
conStr = "workstation id=" + ServerName + ";packet size=4096;user id=sa;password=" + Pass + ";data...
|
by: JWest46088 |
last post by:
I'm having difficulty trying to figure out how to print a text file from a hash table one line at a time. I have the text file read into the hash table and can print the text file all at once, but I can't seem to figure out how to do it one line at a time.
Here is what I'm trying to do: I want the user to be able to print the text file one line at a time by clicking a button to see the next line.
Example: If text_file1 first line is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |