473,386 Members | 1,693 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,386 software developers and data experts.

How to group by this SQL statement

Hello everyone,

Could you please provide me with some assistance on how to group by a SQL statement when a selected column comes from a subquery. Here is an example of the SQL statement I am trying to write. I don't know what to add to the group by command in order to make it work.


Thanks for your help and guidance

select sa.sa_type_cd,
nvl((select bsegitem.item_cnt
from ps_ci_bseg bseg,
ps_ci_bseg_item bsegitem
where bseg.bseg_id = bsegitem.bseg_id
and bseg.bill_id = ft.bill_id
and bsegitem.item_type_cd = 'WT-UNITS'),0),
sum(ftgl.statistic_amount),
sum(ftgl.monetary_amount) * -1

from ps_ci_sa sa,
ps_ci_sa_type satype,
ps_ci_ft ft,
ps_ci_ft_gl ftgl
where sa.sa_type_cd = satype.sa_type_cd
and sa.sa_id = ft.sa_id
and ft.ft_id = ftgl.ft_id
and trunc(ftgl.journal_date) between '01-Aug-2007' and '31-Aug-2007'
group by sa.sa_type_cd
Sep 28 '07 #1
0 924

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: chowda | last post by:
trying to get to the bottom of this for some time...... eventually to be used with asp. heres the problem the following rather complex SQL statement works fine via query analyser: SELECT...
4
by: Chad Richardson | last post by:
I've always been mistified why you can't use a column alias in the group by clause (i.e. you have to re-iterate the entire expression in the group by clause after having already done it once in the...
4
by: ree32 | last post by:
I know when you are using group by functions you have to include all the columns in the GROUP BY clause. But what I am having problems when using a case statement to determine whether to sum of...
8
by: | last post by:
hi, i have a table( tblUpdate) with the following fields UpdateID, UpdateDate, ActionID UpdateID is the primary key ActionID is a foreign key i want to find the latest (by date) update...
5
by: Amadelle | last post by:
Hi All and thanks in advance, I was wondering what is the best way of grouping data in a dataset. Like using a "Group By" clause in Sql statements. I was thinking of using XML but I don't even...
1
by: A_PK | last post by:
I got one field, NOTE, its type is Ntext field. I have problem when query the statement using GROUP BY, could some pls kindly guide me. please found the sql query below... SELECT...
1
by: jatinder.saundh | last post by:
Hi, How do I give create database privielege to a specific user/group at a particular db2 instance ? I read about various authorities like SYSCTRL etc. but I am interested in giving only Create...
1
by: hstello | last post by:
I have a rather simple SQL statement, but I can't get it to work properly. I have four columns in the activities table "LoginID", "StartDateTime", "StopDateTime", and "ProjectID". In a second...
3
by: ylekot88 | last post by:
Hi I am a student, I am trying to figure this out. I am trying to run a select statement that is asking for customer#, date, and total price of each order. ensure results are in chronological...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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
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.