Hi,
Can someone help to write a query that will sum the information across the row, not down the column.
nome_item Sunday Monday Tuesday Wednesday Thursday Friday Total
item1 12 5 5 9 4 23 58
item2 2 6 2 2 45 3 60
item3 3 7 3 3 4 3 23
item4 4 8 4 4 4 5 29
4 28805
Hi,
Can someone help to write a query that will sum the information across the row, not down the column.
nome_item Sunday Monday Tuesday Wednesday Thursday Friday Total
item1 12 5 5 9 4 23 58
item2 2 6 2 2 45 3 60
item3 3 7 3 3 4 3 23
item4 4 8 4 4 4 5 29
You just add up the columns like this: -
SELECT nome_item, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,
- Sunday+Monday+Tuesday+Wednesday+Thursday+Friday as Total
-
FROM mytable
-
-
You just add up the columns like this: -
SELECT nome_item, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,
- Sunday+Monday+Tuesday+Wednesday+Thursday+Friday as Total
-
FROM mytable
-
-
------------------------------------------------------------------------------------------------------------
I run the query, but it's the results of the Total column is '0'.
Do you have any idea?
------------------------------------------------------------------------------------------------------------
I run the query, but it's the results of the Total column is '0'.
Do you have any idea?
It works fine (I tried) so long as your days columns are of numeric type (i.e. int). If they are string (char, varchar -- why?), you need to cast them like this: -
SELECT nome_item, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,
-
cast(Sunday as int)+...+cast(Friday as int) as Total
-
FROM mytable
-
It works fine (I tried) so long as your days columns are of numeric type (i.e. int). If they are string (char, varchar -- why?), you need to cast them like this: -
SELECT nome_item, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,
-
cast(Sunday as int)+...+cast(Friday as int) as Total
-
FROM mytable
-
__________________________________________________ ________
Thanks!!!
This works very fine!!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jochem |
last post by:
Hello,
Lately I came accross this problem a couple of times, and I know there
must be a clever solution. However, I did not find it untill now.
When I add a entry to my mysql database from a...
|
by: Paul Hallam |
last post by:
How does oracle distribute records in a table that is in a tablespace
with multiple datafiles.
Very simplisticly Ingres will distribute sequential records evenly
across multiple datafiles for a...
|
by: iffriganovitch |
last post by:
Hello,
My records contain a position, from 1 to n.
This position is not the primary key.
In normal conditions, the position of this records should be as
follows:
1, 2, 3, 4, 5, 6, 7, 8, 9...
|
by: Conner |
last post by:
Hi Bob,
I know this reply is a little late for you but I just came accross
your post. You might be interested to know that there is a pretty good
query tool available on download.com called...
|
by: Jeff |
last post by:
Access 97
I have three single digit feilds and would like to query on only two
of them however, the data is accross all three fields.
Exsample:
Query for 34 would return:
340
304
|
by: Christine |
last post by:
It has come to my attention that sometimes, when I open a Query in SQL
View, the SQL that I see is not exactly the same as the SQL in the
Query's Querydef. The difference I see (only occasionally)...
|
by: Hans |
last post by:
Hi,
I want to allow users to start my application only once. To do so, I use
Process Processes = Process.GetProcessesByName("MyApp");
to get all processes running on the machine and compair...
|
by: sar68 |
last post by:
I'm using Access 2007 on windows vista. Intel T7400 with 2.16 GHz and 2 gigs of ram. 64 bit os.
If I run a query that goes across multiple tables, I get sensible results. However, if I run a...
|
by: cephal0n |
last post by:
Hi everyone!
I've been studying SELECT INTO in vba and made my own. I was successful in generating my own table,
strSql = "SELECT * INTO tblTemp49 FROM qryUnq49"
conn.Execute strSql
now I...
|
by: dizzydangler |
last post by:
Hi, I'm new to access (2007, running on XP), but I've gotten some great help from this site on my project so far. However, the more I know, the more complex the problems seem to become....
I'm...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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: 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...
|
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,...
|
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...
| |