Hi,
The sql query below returns data in the 'note' field from a table
called ww_rec_1 from the previous month and displays the sum of hours
for each category.
SELECT note,SUM(hours) FROM WW_REC_1
where trans_date between
last_DAY(ADD_MO NTHS(SYSDATE, -2))+1
and LAST_DAY(ADD_MO NTHS(SYSDATE,-1))
GROUP BY NOTE
This is the returned data:
"NOTE", "SUM(HOURS) "
"ACT", -330864.75
"CHG", -165.25
"EXT", 331108.5
"INT", 45
I need to add together the sum of hours for specified data in the note
field. So in this case I want to add together the sum of hours for
'ACT' and 'CHG'. I also need to add together the sum of hours for
'EXT' and 'INT'.
Can anyone help me out with this?
Thanks in advance
George 3 15466 ge***********@e u.watsonwyatt.c om (George) wrote in message news:<d4******* *************** ****@posting.go ogle.com>... Hi,
The sql query below returns data in the 'note' field from a table called ww_rec_1 from the previous month and displays the sum of hours for each category.
SELECT note,SUM(hours) FROM WW_REC_1 where trans_date between last_DAY(ADD_MO NTHS(SYSDATE, -2))+1 and LAST_DAY(ADD_MO NTHS(SYSDATE,-1)) GROUP BY NOTE
This is the returned data:
"NOTE", "SUM(HOURS) "
"ACT", -330864.75 "CHG", -165.25 "EXT", 331108.5 "INT", 45
I need to add together the sum of hours for specified data in the note field. So in this case I want to add together the sum of hours for 'ACT' and 'CHG'. I also need to add together the sum of hours for 'EXT' and 'INT'.
Can anyone help me out with this?
Thanks in advance
George
First, this probably should have been posted to
comp.databases. oracle.misc rather than the obsolete
comp.database.o racle group. When a newsgroup has subgroups you should
generally post to the subgroups and not the group.
There are several ways to solve you query. One method would be to
change the from clase to be a FROM (Select .... where in the new
select you use a case statement to return ACT for CHG and EXT for INT
so that to the outer query the NOTE values are the same group value.
HTH -- Mark D Powell --
> SELECT note,SUM(hours) FROM WW_REC_1 where trans_date between last_DAY(ADD_MO NTHS(SYSDATE, -2))+1 and LAST_DAY(ADD_MO NTHS(SYSDATE,-1)) GROUP BY NOTE
This is the returned data:
"NOTE", "SUM(HOURS) "
"ACT", -330864.75 "CHG", -165.25 "EXT", 331108.5 "INT", 45
I need to add together the sum of hours for specified data in the note field. So in this case I want to add together the sum of hours for 'ACT' and 'CHG'. I also need to add together the sum of hours for 'EXT' and 'INT'.
1. add together ...
SELECT SUM(hours) FROM WW_REC_1
where trans_date between
last_DAY(ADD_MO NTHS(SYSDATE, -2))+1
and LAST_DAY(ADD_MO NTHS(SYSDATE,-1))
where note='ACT' OR note='CHG'
2. also add together ...
SELECT SUM(hours) FROM WW_REC_1
where trans_date between
last_DAY(ADD_MO NTHS(SYSDATE, -2))+1
and LAST_DAY(ADD_MO NTHS(SYSDATE,-1))
where note='EXT' OR note='INT'
select sum ( sum_hours ),
note_group
from (
select decode
(
note,
'ACT', 'ACT-CHG',
'CHG', 'ACT-CHG',
null
) note_group,
decode
(
note,
'EXT', 'EXT-INT',
'INT', 'EXT-INT',
null
) note_group,
sum_hours
from (
SELECT note,SUM(hours) sum_hours FROM WW_REC_1
where trans_date between
last_DAY(ADD_MO NTHS(SYSDATE, -2))+1
and LAST_DAY(ADD_MO NTHS(SYSDATE,-1))
GROUP BY NOTE
)
)
group by
note_group;
Pratap
Cognizant Technology Solutions, India This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tcs |
last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't
loaded it yet. I'm still using MS Access. And no, I don't believe this is an
Access question. (But who knows? I COULD be wrong... :) I've tried the
access group...twice...and all I get is "Access doesn't like ".", which I know,
or that my query names are too long, as there's a limit to the length of the SQL
statement(s). But this works when I don't try to...
|
by: Andrew McNab |
last post by:
Hi folks,
I have a problem with an MS Access SQL query which is being used in an
Access Report, and am wondering if anyone can help.
Basically, my query (shown below) gets some records from a couple of
tables in my database using INNER JOINS and the WHERE clause to
specify the required constraints. However, I also want to read two
fields from a *single* record from a table called 'Locations' and then
apply one of these field's values...
|
by: davidboyd24 |
last post by:
Im currently having difficulty trying to write an SQL query in Access
which will add two columns together to calculate a totals column. For
example...
I was hoping to get the below resultset from my query, e.g.
"select name, hours, overtime, hours+overtime as total"
Name Hours Overtime Total
--------------------------------------
Bloggs 8 2 10
|
by: marco |
last post by:
Dear List,
as it seems, MS SQL as used in Access does not allow a select INTO
within a UNION query. Also, it seems that a UNION query can not be used
as a subquery.
Maybe my (simplified) problem can avoid these technicalities: the
original table has columns
A1, A2, B1, B2, C1, C2.
|
by: Rob Woodworth |
last post by:
Hi,
I'm having serious problems getting my report to work. I need to
generate a timesheet report which will contain info for one employee between
certain dates (one week's worth of dates). I have a table containing
records for each job done, the records contain date, employee name, job done
(a code representing the type of job), cost code (another code), regular
hours, and overtime hours. The tricky part is that more than one job can...
| |
by: Noob |
last post by:
ftp://ukcassassin:winston@www.ukcassassin.pwp.blueyonder.co.uk/htdocs/Diary%20Form.bmp
Hi all
I will appologise in advance for my lack of knowledge of access and its working as i am quite new to the program and have been self taught, so here goes.
As you can see by the image link i am creating an appointment diary for a garage,its going ok untill i created the "Hours remaing" text box The main subform adds up the hours booked in and...
|
by: djpaul |
last post by:
Hello guys,
I'm busy writing a website for dj's.
But i wanted to show the picture and more stuff of the dj who's playing music between a few hours.
Let's say he works between 18:00 and 21:00 on wednesday.
I created a table begin_time and a table end_time and day.
Then i wanted to compare the times with the local time like$time = date("H");
$day = date("l");.
I thought something like this query:
$query = "SELECT * FROM dj WHERE...
|
by: Mike1961 |
last post by:
Hi there.
Well the situation is this, I have two tables:
1) tbl_registry where rows with code = 123 are 35 ;
1) tbl_Registered where rows with code = 123 are 43
In tbl_Registered I have it 7 rows more respect tbl_registry can you tell my why I have this situation:
|
by: George |
last post by:
Hi,
The sql query below returns data in the 'note' field from a table
called ww_rec_1 from the previous month and displays the sum of hours
for each category.
SELECT note,SUM(hours)FROM WW_REC_1
where trans_date between
last_DAY(ADD_MONTHS(SYSDATE, -2))+1
and LAST_DAY(ADD_MONTHS(SYSDATE,-1))
|
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: 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.
| |