I have a SELECT * query that returns info such as 'name', 'date',
'cost', and 'notes'. At the head of this query return it reads how
many records were found. I would like to append that with 'how many
records were found at a cost of' ...
But haven't been able to find a means of totalizing the 'cost' column
in my query. Does anyone have any ideas on how this might be
accomplished ??? I've spent considerable time on the net looking at
examples and my reference book but so far, no luck.
TIA,
Chris 3 1621
Chris (co**********@y ahoo.com) wrote:
: I have a SELECT * query that returns info such as 'name', 'date',
: 'cost', and 'notes'. At the head of this query return it reads how
: many records were found. I would like to append that with 'how many
: records were found at a cost of' ...
: But haven't been able to find a means of totalizing the 'cost' column
: in my query. Does anyone have any ideas on how this might be
: accomplished ??? I've spent considerable time on the net looking at
: examples and my reference book but so far, no luck.
The row count you see is extra information, it is not part of the query,
and what sort of information you can get depends on the application you
are using. Something like mysql will give you basic feedback such as the
row count. If you used a report application then you could ask the report
application to provide a sum at the end, but otherwise you have to
calculate it your self. If you used a report application then it would
simply be doing something like what I describe below.
There are two basic ways to do it your self
-1- do the sum yourself as you scan through the rows
(pseudo code, based on some mysql/php examples I have)
$sum = 0;
while($row = mysql_fetch_arr ay($sth))
{
$sum += $row[cost];
Print_the_row($ row);
}
Print_the_cost( $sum);
-2- or use two queries
mysql> select * from query;
mysql> select sum(cost) from query;
--
This space not for rent.
On 28 May 2005 13:45:10 -0800, Malcolm Dew-Jones wrote: $sum += $row[cost];
Array indices are numeric or string, not constant. It works because it
used to work in ancient php, but you should really say:
$sum += $row['cost'];
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Ewoud Dronkert (fi*******@last name.net.invali d) wrote:
: On 28 May 2005 13:45:10 -0800, Malcolm Dew-Jones wrote:
: > $sum += $row[cost];
: Array indices are numeric or string, not constant. It works because it
: used to work in ancient php, but you should really say:
: $sum += $row['cost'];
good point thanks.
--
This space not for rent. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tryfon Gavriel |
last post by:
Hi all
I recently noticed when trying to optimise a major query of a chess website
I am the webmaster of, that adding an order by for "gamenumber" which is a
clustered index field as in for example "order by timeleft desc, gamenumber
desc" actually speeded up the queries and reduced sql server 2000 timeouts.
I have an ASP error log and I am fairly sure that a dramatic reduction in
sql server timeouts is simply attributed to adding an...
|
by: GL |
last post by:
Hi,
Is there a way to add a field to an existing table using a query of
some sort (without needing to manually add a field to the table). I
know how to do it with a make table query, but I have a specific need
to only add a new field to a table if possible. Here's a simplified
example of what I'm trying to do:
I get a file with the following two fields:
First Name
|
by: Viorel |
last post by:
Adding new row with default values.
In order to insert programmatically a new row into a database table, without
direct "INSERT INTO" SQL statement, I use the well-known DataTable.NewRow,
DataTable.Rows.Add and DataAdapter.Update member functions. Before adding
the new row object to the Rows collection, all of the row's fields that do
not accept NULL must be assigned, otherwise an exception is thrown. However,
I do not want to assign...
|
by: Robin Thomas |
last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental.
Anyway, quite often I am pulling data from a database, but then I need to
use that data to produce more data. A simple example would be: Let's say
Column1=StartDate and Column2=EndDate. In addition to displaying Column1 and
Column2, I need to do some calculations and display in as Column3.
The calculations are easy and can be done in the code-behind. How to display...
|
by: Rudy |
last post by:
Hi all,
I know this is easy, just can't seem to get it. I have a windows form, and
a text box, with a value already in it. I need to add that value to a table.
It's just one value, so the entire row doesn't get filled. I have a
connection and all that stuff.
Private Sub btnPlaceBet_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPlaceBet.Click
' Dim Myds As Footbet.DStable
'...
| |
by: John Siracusa |
last post by:
I recently had a problem where a bunch of postgres backends were taking up
huge amounts of CPU time. I found a bunch of log messages like this:
NOTICE: adding missing FROM-clause entry for table "b"
Which I eventually tracked to an improperly constructed query that reduced
to something like this:
select a1, a2 FROM a WHERE a1 = '...' AND b.b1 = '...';
|
by: ljungers |
last post by:
Hi to all and hope someone may have an answer for me.
I have a Form named Cust_lukup_Form that has 3 text boxes and a click button that uses a OnClick to call Cust_lukup_Macro that runs an OpenQuery named Cust_lukup_Query using the text box(s) input data running in print view mode. The Cust_lukup_Query has the code setup to query the 3 fields using 1, 2 or 3 of the boxes or selecting all if there blank.
What I need to do is add another...
|
by: dympna |
last post by:
Hi can anyone suggest a fix for this... as I am a novice in access.
I have created a training table with the following fields
Employee Name - joe
Training Received - Fork lift
Date Received - 20/6/07
Certificate - yes
What I want to create is a renewal date for this training, there are
|
by: uno7031 |
last post by:
Help Please!!! Adding 5 Days to another Date in an access query
Good Morning,
Help please…. I am new to access and trying to write a query that will add 5 days between a RecDate and a DLPayDate
I created the query in design view of access.
Current Query: SELECT PaymentCalculator2.ID, PaymentCalculator2.RecDate, DateAdd("w",5+1,) AS DLPayDate, DateAdd("w",5,) AS DLPayDate2
FROM PaymentCalculator2
WHERE...
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |