Get AccountItems That Has Max Revenue For Each Account
Aug 22, 2010
I been working on this for days but I just cannot get it working...I have 3 tables:
1- Account
2- AccountItems
3- AccountInfo
Account has many AccountItems and has only 1 AccountInfo.So the point is to get the Account tems that has the max revenue for each Account. The field for revenue is AccountItems.Revenue..So here's what I did
Select Account.Name, Account.Telno, AccountItems.Item, AccountInfo.FirstName, AccountInfo.LastName
where Account.ID = AccountItems.ID
AND AccountItems.ID = AccountInfo.ID
AND ????
From Account, AccountInfo, AccountItems;
This is where I'm stucked on...I don't know what to do in order to grab the AccountItems.Item that has the MAX AccountItems.Revenue.
View 2 Replies
Aug 16, 2011
I have a table revenue
create table revenue
(
person varchar2(23),
month varchar2(3),
rev_amt number
)
and i have data in a file like below
Person Jan Feb Mar Apr Mai Jun Jul Aug Sep Oct Nov Dez
--------------------------------------------------------
Schnyder,345,223,122,345,324,244,123,123,345,121,345,197
Weber,234,234,123,457,456,287,234,123,678,656,341,567
Keller,596,276,347,134,743,545,216,456,124,753,346,456
Meyer,987,345,645,567,834,567,789,234,678,973,456,125
Holzer,509,154,876,347,146,788,174,986,568,246,324,987
Müller,456,125,678,235,878,237,567,237,788,237,324,778
Binggeli,487,347,458,347,235,864,689,235,764,964,624,347
Stoller,596,237,976,876,346,567,126,879,125,568,124,753
Marty,094,234,235,763,054,567,237,457,325,753,577,346
Studer,784,567,235,753,124,575,864,235,753,864,634,678
i want to load it into the table in the following way.
Person Month Revenue
-------------------------
Schnyder Jan 345
Schnyder Feb 223
Schnyder Mar 122
Schnyder Apr 345
Schnyder Mai 324
Schnyder Jun 244
Schnyder Jul 123
Schnyder Aug 123
Schnyder Sep 345
Schnyder Oct 121
Schnyder Nov 345
Schnyder Dez 197
........ ... ...
How to write control file to load this data into the above revenue table.
View 2 Replies
View Related
Jun 3, 2011
I'm trying to write a query where I grab the first contact created of an account. I've tried everything but I can't get this to work.
Here is the normal query we used to get the contacts from an account:
select
con.row_id,
con.created,
con.fst_name,
con.last_name,
con.email_addr
from s_contact con
join s_org_ext org
on org.row_id = con.pr_dept_ou_id
I've tried different variation of aggregate functions, but its not working.
View 5 Replies
View Related
Nov 23, 2008
I gave this a shot on my own, and failed, so I am putting the question to you:
I am looking to create a trigger on the "Account" table
CREATE TABLE Account(Acct_no number, BillAmt number, OpenDate Date, SSN number,
Primary Key (Acct_no),
Foreign Key(SSN) references ResponsibleParty(SSN));
which will update the BillAmt field whenever one of the account's respective records is inserted/updated/deleted from the following tables:
CREATE TABLE Plan(Plan_id number, Cost number, Minutes number,
primary key(Plan_id));
CREATE TABLE Feature(Feature_id number, Description varchar(20), Cost number,
primary key(Feature_id));
These tables are linked through the following table:
CREATE TABLE Phone_Line(MTN number, cStart Date, cEnd Date,
rDate Date, Status char, ESN number, Acct_no number, Plan_id number,
primary key(MTN),
foreign key(ESN) references Equiptment(ESN), foreign key( Acct_no) references Account(Acct_no),
foreign key(Plan_id) references Plan(Plan_id));
View 26 Replies
View Related
Apr 25, 2013
I want Hierarical query to display my Chart_Of_Account. I want to make a tree Form in 6i error i am getting is connect by nocycle prior account_code=parent_code
*
ERROR at line 4:
ORA-00920: invalid relational operator
Table
Create Table Chart_Of_Account (Account_Code Char(19), Account_Title varchar2(70), Parent_Code Char(19))
insert into Chart_Of_Account ('DGHOA01010101000001','TEST','DGHOA01010100000000')
insert into Chart_Of_Account ('DGHOA01010101000002','TEST1','DGHOA01010100000000')
insert into Chart_Of_Account ('DGHOA01010101000003','TEST2','DGHOA01010100000000')
select -1,level,account_code||' - '||ACCOUNT_Title,'NULL',to_char(ACCOUNT_CODE)
connect_by_iscycle from chart_of_account
start with Substr(account_code,13,7)='0000000'
connect by nocycle prior account_code=parent_code
View 3 Replies
View Related
Jun 28, 2012
I have altered an user account and set the account status as expired.When I tried to connect with that user, oracle prompted for changing password.
But, after I changed the password, I got an error message as ora-01017 invalid username/password logon denied password unchangedWhat is the cause and solution for it? I am using 11g database and 10g client.
View 15 Replies
View Related
Feb 23, 2007
I am succeeded to send mail (through my comapany mail server) using following pl/sql. But, i am unable to send mails using the same coding, when i connected to smtp.gmail.com. i received the following error :
ERROR at line 1:
ORA-29279: SMTP permanent error: 530 5.7.0 Must issue a STARTTLS command first
y78sm463148pyg
ORA-06512: at "SYS.UTL_SMTP", line 17
ORA-06512: at "SYS.UTL_SMTP", line 98
[code]...
Then I received the following error message:
ERROR at line 1:
ORA-29278: SMTP transient error: 454 TLS not available due to temporary reason
ORA-06512: at "SYS.UTL_SMTP", line 17
ORA-06512: at "SYS.UTL_SMTP", line 96
[code]...
my demo_mail package body coded as
FUNCTION begin_session RETURN utl_smtp.connection IS
conn utl_smtp.connection;
BEGIN
-- open SMTP connection
[code]...
View 2 Replies
View Related
Dec 10, 2012
Here are the relevant tables to the triggers I'm having trouble with.
create table profile
(
userID number(10),
uname varchar2(64),
email varchar2(32),
password varchar2(32),
date_of_birth date,
[code]...
Here's the triggers I currently have that doesn't work.
create or replace trigger DropAccount
after delete on profile
FOR EACH ROW
BEGIN
delete from groupMembership where (userID = :old.userID);
END;
The DropAccount trigger's purpose is to delete all the records from groupMembership that contains the userID of the person deleting his/her own account. It appears to work when I run the following statements in sqlplus:
delete from profile where (userID = '1');
select * from groupMembership where (userID = '1');
But when I try to delete an account through a java interface using JDBC I get the following error:
Machine Error: java.sql.SQLException: ORA-04091: table *****.GROUPMEMBERSHIP is mutating, trigger/function may not see it
ORA-06512: at "*****.DROPACCOUNT", line 2
ORA-04088: error during execution of trigger '*****.DROPACCOUNT'
The java function basically just executes a delete statement.
View 1 Replies
View Related