Help with GROUP BY with SUM

Hello all:
I have always struggled with getting this right, so hopefully someone can assist with this. 
Basically I have two tables:
CREATE TABLE [dbo].[Placement](
[PlacementID] [int] IDENTITY(1,1) NOT NULL,
[TravelerID] [int] NOT NULL,
[ActivityTypeID] [int] NULL,
[ActivityStatusID] [int] NULL,
[StartDate] [datetime] NULL,
[EndDate] [datetime] NULL,
[NumberOfWeeks] [int] NULL,
[BookingCompanyID] [int] NOT NULL
CREATE TABLE [dbo].[TravelerCompanyData](
[TravelerID] [int] NOT NULL,
[CompanyID] [int] NOT NULL,
[StatusID] [int] NOT NULL
I am trying to join the placement table to the TravelerCompanyData table so that I only get one row per TravelerID. The point of this query is to sum up the number of weeks. So I want to sum the number of weeks of Placements that have been completed (if
any), and add them to however many week the person has been currently on assignment. I cannot use the NumberOfWeeks column if a placement is currently "On Assignment" because it counts the number of weeks from the start date to the end date, and
the Traveler will not be all the way to the end date yet.
However, I think with my SUMs in there and all the columns I am referencing in the CASE statement, I am not getting the grouping right. 
The query below will yield four columns, one for each sum because there are four separate rows in the placement table that fit the criteria of the JOIN/WHERE
Some notes:
ActivityStatusID = 23 means the placement status is "on assignment"
= 24 means the placement in "complete"
CompanyID 10 and 12 are the only companies that I want to fit this summing criteria. 
I am using only one travelerID to simplify the result set. 
SELECT
trav.TravelerID
,CASE
WHEN p2.EndDate IS NULL -- Not on assignment, can sum number of weeks
THEN SUM(p.NumberOfWeeks)
ELSE -- multiple assignments, count weeks
CASE
WHEN (DATEDIFF(day, p2.StartDate, GETDATE()) + 1) % 7 < 3
THEN (DATEDIFF(day, p2.StartDate, GETDATE()) + 1) / 7
+
ISNULL(p.NumberOfWeeks,0)
WHEN (DATEDIFF(day, p2.StartDate, GETDATE()) + 1) % 7 >= 3
THEN (DATEDIFF(day, p2.StartDate, GETDATE()) + 1) / 7 + 1
+
ISNULL(p.NumberOfWeeks,0)
END
END AS WksOnAssignment
FROM TravelerCompanyData trav
-- Completed placements ------------------
LEFT JOIN dbo.Placement p ON p.TravelerID = trav.TravelerID
AND p.ActivityStatusID IN (24)
AND trav.CompanyID = p.BookingCompanyID
-- Placement if on assignment ------------
LEFT JOIN dbo.Placement p2 ON p2.TravelerID = trav.TravelerID
AND p2.ActivityStatusID IN (23)
AND trav.CompanyID = p2.BookingCompanyID
WHERE ( trav.CompanyID IN (10,12))
AND
( p.PlacementID IS NOT NULL
OR
p2.PlacementID IS NOT NULL )
AND trav.TravelerID = 31788
GROUP BY trav.TravelerID
,p.NumberOfWeeks
,p2.StartDate
,p2.EndDate
If I add the NumberOfWeeks column in, it is adding that number to the number of weeks the current On Assignment placement currently has for each row (56 weeks), but I need to add that 56 weeks to the sum of the NumberOfWeeks column. Here is the result set:
TravelerID NumberOfWeeks WksOnAssignment
31788 8 64
31788 12 68
31788 25 81
31788 33 89
So am I joining wrong, grouping wrong, or summing wrong? 
Thanks so much for any pointers!!!

Thanks for the reply. I did some more experimenting and I discovered I don't need the SUM in this case at all. I get the same results when remove the SUM completely, but still GROUP BY the same columns. 
Alternatively, if I SUM and the only GROUP BY tcd.TravelerID, I will get one row, but it is summing each NumberOfWeeks value by the result of the expression. 
Query where I have included the NumberOfWeeks from the p Placement join, and the StartDate and EndDate of p2 Placement table (on assignment match) - NOTE: I have noticed that with this query, the SUM makes no difference:
SELECT
trav.TravelerID
,p.NumberOfWeeks
,p2.StartDate
,p2.EndDate
,CASE
WHEN p2.EndDate IS NULL -- Not on assignment, can sum number of weeks
THEN p.NumberOfWeeks
ELSE -- multiple assignments, count weeks
CASE
WHEN (DATEDIFF(day, p2.StartDate, GETDATE()) + 1) % 7 < 3
THEN (DATEDIFF(day, p2.StartDate, GETDATE()) + 1) / 7
+
ISNULL(p.NumberOfWeeks,0)
WHEN (DATEDIFF(day, p2.StartDate, GETDATE()) + 1) % 7 >= 3
THEN (DATEDIFF(day, p2.StartDate, GETDATE()) + 1) / 7 + 1
+
ISNULL(p.NumberOfWeeks,0)
END
END AS WksOnAssignment
FROM TravelerCompanyData trav
-- Completed placements ------------------
LEFT JOIN dbo.Placement p ON p.TravelerID = trav.TravelerID
AND p.ActivityStatusID IN (24)
AND trav.CompanyID = p.BookingCompanyID
-- Placement if on assignment ------------
LEFT JOIN dbo.Placement p2 ON p2.TravelerID = trav.TravelerID
AND p2.ActivityStatusID IN (23)
AND trav.CompanyID = p2.BookingCompanyID
WHERE ( trav.CompanyID IN (10,12))
AND
( p.PlacementID IS NOT NULL
OR
p2.PlacementID IS NOT NULL )
AND trav.TravelerID = 31788
GROUP BY trav.TravelerID
,p.NumberOfWeeks
,p2.StartDate
,p2.EndDate
Gives:
TravelerID NumberOfWeeks StartDate EndDate WksOnAssignment
31788 8 2013-04-01 2014-10-04 64
31788 12 2013-04-01 2014-10-04 68
31788 25 2013-04-01 2014-10-04 81
31788 33 2013-04-01 2014-10-04 89
See it is summing correctly on the row, but how can I get it to sum the NumberOfWeeks column and add it to 56, which is what the calculation yields from the StartDate of the "On Assignment" placement from p2 until today's date?
Hope that makes sense! 

Similar Messages

  • Help with Sum using FormCalc in Livecycle

    Hello. I'm stuck. I've been doing searches, readings, and all that on how to sum up certain cells in Livecycle. I have tried examples and tutorials and I get stuck when the application says "Error: Accessor ' ' Unknown".
    I'm such a novice in using Livecycle and I'm not a programmer. So, if someone can help me on why it does this, that would be awesome!

    Here you go.  I rename it.  Couple of things.  Too many subforms (unless you intend to do something else with this).  Also, make sure you save your forms as "dynamic" if you intend to have user enter info.  I couldn't tell if you were importing/exporting to a spreadsheet.  Note the formcalc.  Your fields need to be named the same.  In my example they are: ExpCosts.
    I'm not very good with the formcalc/java and variables but am more than willing to help with what I can

  • Help with SUM function ??

    Hi,
    I am trying to build a SUM function into the following SELECT statement;
    SELECT   emp_code "EmployeeCode", trn_date "TransactionDate", project "ProjectCode",
    phase_code "PhaseCode", task_code "TaskCode", reg_hrs "RegularHoursAmt", rate_reg "RegularHoursRate", ot_hrs "OvertimeHoursAmt", rate_ot "OvertimeHoursRate"
    Currently when i do the extract to xls I manually compile the "RegularHoursAmt" and "RegularHoursRate" manually and it's quite a task. I'm sure it can be completed in teh SELECT but I'm not clear on how and it's been quite some time since my last foray into SQL. Any assistance appreciated.
    I need to sum "RegularHoursAmt" and "RegularHoursRate"
    per "EmployeeCode"
    by "TransactionDate"
    with unique combo of "ProjectCode", "PhaseCode", "TaskCode"
    Cheers, Peter

    Hi, Peter,
    PJS5 wrote:
    Thanks Frank for the quick response. Ok, here goes;
    The TABLES already exist and I am only pulling the data for the columns in my SELECT statement so no CREATE of INSERT as such.Post CREATE TABLE and INSERT statements so that the people who want to help you can re-create the problem and test their ideas.
    The data is in Oracle 10g 10.1.0.2.0Perfect!
    So you want totals that represent the entire day for a given employee.
    Yes, but rows are by the unique combo per employee of "ProjectCode", "PhaseCode", "TaskCode"So a row of output will represent a distinct combination of employee, day, ProjectCode, PhaseCode and TaskCode, and that one output row may correspond to more than one row of input; is that right?
    eg Tom works on 4 unique "ProjectCode/PhaseCode/TaskCode" efforts on "TransactionDate"What does "effort" mean here? If I could look at some actaul data (or actual fake data; don't post anything like real credit card numbers) and the results you want from that data, perhaps it would be clear.
    One of those unique "ProjectCode/PhaseCode/TaskCode" efforts however has 3 timesheet entries as he has added unique Descriptions of what his efforts were aimed at achieving.
    We are not extracting the Descriptions and thereby want to SUM those 3 timesheet entries into one row.
    Do you also want a total for each employee, over all days? No thanks
    Do you want a grand total for all employees and all days? No thanks
    Do you want the totals on the same output rows as your current reuslts? That would be handy
    If so, use the analytic SUM function. I'm not familiar with this
    Do you want separate rows for the the totals? That could helpPost the exact results you want from a small set of given data. It's fine to describe the results, as you did above, but describe them in addition to (not instead of) actually showing them.
    Does that make my questions easier to follow?It looks good, but without some sample data and the results you want from that data, I can't say for sure.
    Please post CREATE TABLE and INSERT statements (relevant columns only) for a little sample data, so that I (and the others who want to help you) can see exactly what your tables are like, and actually try our solutions. Simplify as much as possible. For example, if the data is actually coming from a multi-table join, but you already know how to join all the tables perfectly, then pretend all the data is in one table, and post CREATE TABLE and INSERT statements for that one table that looks sort of like your current result set. Post just enough data to show what you want to do. Based on what you've said so far, I'm guessing that 10 to 20 rows of raw data, resulting in 3 to 7 rows of output could give a nice example.
    Also, post the exact results you want from the sample data you post. Explain, with specific examples, how you get those results from that data.
    If parts of your desired output are optional (that is, if some parts "would be handy" or "could help") then post a couple of different sets of results from the same data, and explain, something like this:
    "What I'd really love to get for results is" ...
    but, if that makes things really complicated or inefficient, I don't absolutely need ... or ...,
    so I'd settle for these results: ..."
    I know it's a lot of work to post all this information, but it's really necessary. If I could help you without making you do all this, then I would. Unfortunately, I really don't have a good idea of where you're coming from or where you want to go.
    Edited by: Frank Kulash on Oct 19, 2010 8:01 PM

  • Help with SUM subquery

    I have an existing query that I wish to have 3 additional calculated columns added.
    The existing query is:
    SELECT t.swid as ID,
    t.name,
    t.swcatid,
    t2.catdesc as Category,
    t.liccnt,
    (select count(swid) as swcount from swinv t2 where t2.swid=t.swid) Reccnt,
    t.liccnt-(select count(swid) as swcount from swinv t2 where t2.swid=t.swid) as Avail,
    t.last_update_date as updated
    FROM SOFTWARE t
    LEFT OUTER JOIN swcat t2 ON T.swcatid=t2.swcatid
    order by t.name;
    For the first calculated column, I need the sum of the liccnt where the SWIDs have the same GID in the following table:
    TableName = colic
    Columns: CID (primary key)
    GID
    SWID
    I created a query that sums the liccnt in the Software table grouped by GID -- let's call this result (GroupLic):
    SELECT t3.gid, nvl(Sum(t5.LicCnt),0) AS SumOfLicCnt
    FROM CoLic t3 left outer JOIN Software t5 ON t3.SWID = t5.SWID
    GROUP BY t3.gid;
    The 2nd new calculated column should be the total of COUNTS of SWID in the SWInv where the SWID=the SWIDs in the CoLic table -- let's call this result (InstalledGroupLic):
    TableName=SWInv
    Columns: SID (primary key)
    PCID
    SWID
    Last_Update_Date
    I created a query that displays the counts by GID -- let's call this result (InstalledGroupLic)
    SELECT t4.gid, (select count(t6.SID) AS CountofSWInv from swinv t6 where t6.swid=t4.swid) CollInstalled
    FROM CoLic t4;
    The 3rd Calculated column should be the difference between the SumOfLicCnt in GroupLic and CountofSWInv in InstalledGroupLic (SumOfLicCnt -CountofSWInv).
    The columns should display a 0 if there is no record in the CoLic table with the same SWID in the Software table.
    Any assistance with this would be greatly appreciated.
    Thank you in advance.
    Lillianne

    REM INSERTING into COLIC
    Insert into COLIC (CID,GID,SWID) values (1,1,12);
    Insert into COLIC (CID,GID,SWID) values (2,1,13);
    Insert into COLIC (CID,GID,SWID) values (3,2,20);
    Insert into COLIC (CID,GID,SWID) values (4,2,21);
    Insert into COLIC (CID,GID,SWID) values (5,3,40);
    Insert into COLIC (CID,GID,SWID) values (6,3,41);
    REM INSERTING into SWINV
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (46,2,12,to_timestamp('04-JAN-10 12:05:47 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (47,41,12,to_timestamp('04-JAN-10 12:06:34 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (48,43,12,to_timestamp('04-JAN-10 12:06:46 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (49,49,12,to_timestamp('04-JAN-10 12:07:40 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (50,11,12,to_timestamp('04-JAN-10 12:07:50 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (55,56,12,to_timestamp('04-JAN-10 12:11:00 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (137,80,13,to_timestamp('04-JAN-10 01:18:00 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (138,82,13,to_timestamp('04-JAN-10 01:18:28 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (139,83,13,to_timestamp('04-JAN-10 01:18:32 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (140,85,13,to_timestamp('04-JAN-10 01:18:46 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (842,276,20,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (845,275,20,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (848,272,20,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (1229,197,20,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (1232,207,20,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (1235,214,20,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (7,101,40,to_timestamp('31-DEC-09 03:24:43 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (336,47,41,to_timestamp('05-JAN-10 10:29:27 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (545,259,41,to_timestamp('05-JAN-10 04:33:30 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (372,35,78,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (373,35,152,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (374,36,19,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (855,270,78,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (856,270,152,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (857,269,19,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (859,269,152,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (862,278,78,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (865,273,19,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (885,254,78,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (886,254,152,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (887,250,19,to_timestamp('05-JAN-10 10:48:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (771,265,221,to_timestamp('08-JAN-10 05:17:17 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (772,250,221,to_timestamp('08-JAN-10 05:17:30 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (787,261,225,to_timestamp('08-JAN-10 05:22:22 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (788,262,225,to_timestamp('08-JAN-10 05:22:31 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (789,145,226,to_timestamp('08-JAN-10 05:22:57 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (790,230,226,to_timestamp('08-JAN-10 05:23:08 PM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (791,268,235,to_timestamp('11-JAN-10 09:32:08 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (792,210,240,to_timestamp('11-JAN-10 09:33:16 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (793,163,249,to_timestamp('11-JAN-10 09:34:30 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWINV (SID,PCID,SWID,LAST_UPDATE_DATE) values (794,175,251,to_timestamp('11-JAN-10 09:35:20 AM','DD-MON-RR HH.MI.SSXFF AM'));
    REM INSERTING into SOFTWARE
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (2,'Upgrade Advantage',4,to_timestamp('30-DEC-09 05:59:22 PM','DD-MON-RR HH.MI.SSXFF AM'),80);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (3,'Xp Pro Softwars Assurance Upgrade',4,to_timestamp('30-DEC-09 05:59:34 PM','DD-MON-RR HH.MI.SSXFF AM'),152);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (4,'Windows 95',1,to_timestamp('30-DEC-09 05:59:52 PM','DD-MON-RR HH.MI.SSXFF AM'),78);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (5,'Windows 98',1,to_timestamp('30-DEC-09 06:00:06 PM','DD-MON-RR HH.MI.SSXFF AM'),22);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (6,'Windows Me',1,to_timestamp('30-DEC-09 06:00:17 PM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (7,'Windows 2003 Server',1,to_timestamp('30-DEC-09 06:00:27 PM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (8,'Windows 2003 Server R2',1,to_timestamp('30-DEC-09 06:00:35 PM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (9,'Windows 2003 Server R2 W/Software Assurance',1,to_timestamp('30-DEC-09 06:00:44 PM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (10,'Windows 2000 Oem (Tracking Only)',1,to_timestamp('30-DEC-09 06:00:53 PM','DD-MON-RR HH.MI.SSXFF AM'),8);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (11,'Windows Nt 4.0 Workstation',1,to_timestamp('30-DEC-09 06:01:06 PM','DD-MON-RR HH.MI.SSXFF AM'),64);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (12,'Windows 2000 Professional',1,to_timestamp('30-DEC-09 06:01:15 PM','DD-MON-RR HH.MI.SSXFF AM'),83);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (13,'Windows Xp Professional',1,to_timestamp('30-DEC-09 06:01:24 PM','DD-MON-RR HH.MI.SSXFF AM'),245);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (14,'Vista Ultimate',1,to_timestamp('30-DEC-09 06:01:33 PM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (15,'Vista Business',1,to_timestamp('30-DEC-09 06:01:42 PM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (16,'Windows Nt 4.0 Server',1,to_timestamp('31-DEC-09 10:47:06 AM','DD-MON-RR HH.MI.SSXFF AM'),9);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (17,'Software Assure Nt4 Server To W2k Server',1,to_timestamp('31-DEC-09 10:47:43 AM','DD-MON-RR HH.MI.SSXFF AM'),9);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (18,'Cal For Windows Nt 4.0 Server',1,to_timestamp('31-DEC-09 10:47:56 AM','DD-MON-RR HH.MI.SSXFF AM'),50);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (19,'Cal For Windows 2000 Server',1,to_timestamp('31-DEC-09 10:48:03 AM','DD-MON-RR HH.MI.SSXFF AM'),245);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (20,'Cal For Windows 2003 Server',1,to_timestamp('31-DEC-09 10:48:11 AM','DD-MON-RR HH.MI.SSXFF AM'),345);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (21,'Cal For Windows 2008 Server',1,to_timestamp('31-DEC-09 10:48:21 AM','DD-MON-RR HH.MI.SSXFF AM'),30);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (22,'Cal For Microsoft Sql Server 2000',1,to_timestamp('31-DEC-09 10:48:28 AM','DD-MON-RR HH.MI.SSXFF AM'),5);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (23,'Windows 2000 Server',1,to_timestamp('31-DEC-09 10:48:36 AM','DD-MON-RR HH.MI.SSXFF AM'),4);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (24,'Microsoft Sql Server 2000',1,to_timestamp('31-DEC-09 10:48:52 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (25,'Fedora Core3',1,to_timestamp('31-DEC-09 10:48:58 AM','DD-MON-RR HH.MI.SSXFF AM'),4);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (26,'Redhat',1,to_timestamp('31-DEC-09 10:49:05 AM','DD-MON-RR HH.MI.SSXFF AM'),9);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (27,'Redhat Enterprise Server',1,to_timestamp('31-DEC-09 10:49:12 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (28,'Mac Os X 10.1.3',1,to_timestamp('31-DEC-09 10:49:19 AM','DD-MON-RR HH.MI.SSXFF AM'),5);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (29,'Mac Os X 10.1.4',1,to_timestamp('31-DEC-09 10:49:26 AM','DD-MON-RR HH.MI.SSXFF AM'),5);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (30,'Act! 3.0',4,to_timestamp('31-DEC-09 05:02:17 PM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (31,'Activeperl 521',4,to_timestamp('31-DEC-09 10:49:51 AM','DD-MON-RR HH.MI.SSXFF AM'),0);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (32,'Adaptec Easy Cd Creator 4',4,to_timestamp('31-DEC-09 10:49:56 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (33,'Adobe Acrobat 4.0 Full Version',2,to_timestamp('31-DEC-09 05:03:01 PM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (34,'Adobe Acrobat 5.0 Upgrade',2,to_timestamp('31-DEC-09 10:51:41 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (35,'Adobe Acrobat 6.0 Professional Upgrade',2,to_timestamp('31-DEC-09 10:51:47 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (36,'Adobe Acrobat 6.0 Professional',2,to_timestamp('31-DEC-09 10:51:52 AM','DD-MON-RR HH.MI.SSXFF AM'),4);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (37,'Adobe Acrobat 7.0 Professional Upgrade',2,to_timestamp('31-DEC-09 10:51:57 AM','DD-MON-RR HH.MI.SSXFF AM'),5);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (38,'Adobe Acrobat 7.0 Professional Full Version',2,to_timestamp('31-DEC-09 10:52:02 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (39,'Adobe Acrobat 6.0 Upgrade',2,to_timestamp('31-DEC-09 10:52:07 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (40,'Adobe Acrobat 5.0 Standard Full Version',2,to_timestamp('31-DEC-09 10:52:12 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (41,'Adobe Acrobat 6.0 Standard Full Version',2,to_timestamp('31-DEC-09 10:52:18 AM','DD-MON-RR HH.MI.SSXFF AM'),7);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (42,'Adobe Acrobat 7.0 Standard Full Version',2,to_timestamp('31-DEC-09 10:52:23 AM','DD-MON-RR HH.MI.SSXFF AM'),4);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (43,'Adobe Acrobat 8.0 Standard Full Version',2,to_timestamp('31-DEC-09 10:52:27 AM','DD-MON-RR HH.MI.SSXFF AM'),9);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (44,'Adobe After Effects 5.5',2,to_timestamp('31-DEC-09 10:52:32 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (45,'Adobe Creative Suite 3 Web Upgrade (Dreamweaver 8 Mike B)',2,to_timestamp('31-DEC-09 10:52:37 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (46,'Adobe Framemaker 5.5',2,to_timestamp('31-DEC-09 10:52:43 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (47,'Adobe Framemaker V6.0',2,to_timestamp('31-DEC-09 10:52:53 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (48,'Adobe Framemaker 7.0 Upgrade',2,to_timestamp('31-DEC-09 10:52:59 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (49,'Adobe Framemaker 7.0 Full',2,to_timestamp('31-DEC-09 10:53:04 AM','DD-MON-RR HH.MI.SSXFF AM'),0);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (50,'Adobe Framemaker 7.1 Full',2,to_timestamp('31-DEC-09 10:53:09 AM','DD-MON-RR HH.MI.SSXFF AM'),0);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (51,'Adobe Framemaker 7.2 Upgrade',2,to_timestamp('31-DEC-09 10:53:14 AM','DD-MON-RR HH.MI.SSXFF AM'),6);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (52,'Adobe Framemaker 7.2 Full',2,to_timestamp('31-DEC-09 10:53:20 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (53,'Framemaker Archive Plugin',2,to_timestamp('31-DEC-09 10:53:27 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (54,'Framemaker Findchange Plugin',2,to_timestamp('31-DEC-09 10:53:31 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (55,'Framemaker Cleanimport Plugin',2,to_timestamp('31-DEC-09 10:53:36 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (56,'Framemaker Pagelabeler Plugin',2,to_timestamp('31-DEC-09 10:53:40 AM','DD-MON-RR HH.MI.SSXFF AM'),5);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (57,'Framemaker Impgraph Plugin',2,to_timestamp('31-DEC-09 10:53:44 AM','DD-MON-RR HH.MI.SSXFF AM'),6);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (58,'Adobe Illustrator 10',2,to_timestamp('31-DEC-09 10:53:50 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (59,'Adobe Indesign',2,to_timestamp('31-DEC-09 10:53:55 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (60,'Adobe Pagemaker 6.5',2,to_timestamp('31-DEC-09 10:54:12 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (61,'Adobe Photodeluxe Business Edition 1.0',2,to_timestamp('31-DEC-09 10:54:17 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (99,'Corel Essentials',4,to_timestamp('31-DEC-09 10:59:46 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (100,'Cupl For Windows 4.9A',4,to_timestamp('31-DEC-09 10:59:54 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (101,'Crystal Reports 8',4,to_timestamp('31-DEC-09 10:59:58 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (102,'Crystal Reports 9',4,to_timestamp('31-DEC-09 11:00:03 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (103,'Crystal Reports 11',4,to_timestamp('31-DEC-09 11:00:08 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (104,'Data Desk 6.0',4,to_timestamp('31-DEC-09 11:00:14 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (105,'Datapaq Reflow Tracker With Insight Software',4,to_timestamp('31-DEC-09 11:00:23 AM','DD-MON-RR HH.MI.SSXFF AM'),5);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (106,'Descriptions Now',4,to_timestamp('31-DEC-09 11:00:28 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (107,'Designcad 97',4,to_timestamp('31-DEC-09 11:00:36 AM','DD-MON-RR HH.MI.SSXFF AM'),0);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (108,'Designcad Express',4,to_timestamp('31-DEC-09 11:00:41 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (109,'Designcad 3D Max 14',4,to_timestamp('31-DEC-09 11:00:46 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (110,'Designcad Express 15',4,to_timestamp('31-DEC-09 11:00:52 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (111,'Desktop To Go',4,to_timestamp('31-DEC-09 11:00:58 AM','DD-MON-RR HH.MI.SSXFF AM'),22);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (112,'Dream Weaver Mx',4,to_timestamp('31-DEC-09 11:01:04 AM','DD-MON-RR HH.MI.SSXFF AM'),4);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (113,'Dream Weaver Mx 8 Upgrade',4,to_timestamp('31-DEC-09 11:01:12 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (114,'Dream Weaver Mx 8 ',4,to_timestamp('31-DEC-09 11:01:17 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (115,'Dream Weaver 9 Upgrade (Cs3) ',4,to_timestamp('31-DEC-09 11:01:23 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (116,'Dream Weaver Studio Mx',4,to_timestamp('31-DEC-09 11:01:30 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (117,'Dream Weaver Cs3',4,to_timestamp('31-DEC-09 11:01:36 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (118,'Dream Weaver Cs4',4,to_timestamp('31-DEC-09 11:01:40 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (119,'Dream Weaver Mx For Mac',4,to_timestamp('31-DEC-09 11:01:45 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (120,'Dxf Reader ',4,to_timestamp('31-DEC-09 11:01:51 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (121,'Editplus 2',4,to_timestamp('31-DEC-09 11:01:56 AM','DD-MON-RR HH.MI.SSXFF AM'),0);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (122,'Ericom Powerterm 5.4',4,to_timestamp('31-DEC-09 11:02:01 AM','DD-MON-RR HH.MI.SSXFF AM'),61);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (123,'Final Cut Studio 5.1 (Mac) ',4,to_timestamp('31-DEC-09 11:02:07 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (124,'Final Cut Studio 6.0 Upgrade (Mac)',4,to_timestamp('31-DEC-09 11:02:12 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (125,'Filemaker Pro 5.5',4,to_timestamp('31-DEC-09 11:02:17 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (126,'Forticlient',4,to_timestamp('31-DEC-09 11:02:22 AM','DD-MON-RR HH.MI.SSXFF AM'),6);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (127,'Gagetrak Se',4,to_timestamp('31-DEC-09 11:02:28 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (128,'Gibbscam V7.3.5',4,to_timestamp('31-DEC-09 11:02:34 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (129,'Gibbscam 2006 V8.0.19',4,to_timestamp('31-DEC-09 11:02:44 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (130,'Hypersnap-Dx',4,to_timestamp('31-DEC-09 11:02:50 AM','DD-MON-RR HH.MI.SSXFF AM'),5);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (131,'Id Automation Code 128 Font',4,to_timestamp('31-DEC-09 11:02:55 AM','DD-MON-RR HH.MI.SSXFF AM'),6);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (132,'Infralution License System',4,to_timestamp('31-DEC-09 11:03:01 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (133,'Installshield Express 2.11',4,to_timestamp('31-DEC-09 11:03:06 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (134,'Intergraph Smartsketch Le',4,to_timestamp('31-DEC-09 11:03:10 AM','DD-MON-RR HH.MI.SSXFF AM'),10);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (135,'Internet Launcher',4,to_timestamp('31-DEC-09 11:03:15 AM','DD-MON-RR HH.MI.SSXFF AM'),0);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (136,'Ipswitch Ws_Ftp Pro',4,to_timestamp('31-DEC-09 11:03:19 AM','DD-MON-RR HH.MI.SSXFF AM'),0);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (137,'Irfan Viewer',4,to_timestamp('31-DEC-09 11:03:24 AM','DD-MON-RR HH.MI.SSXFF AM'),13);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (138,'Ise Project Importer',4,to_timestamp('31-DEC-09 11:03:30 AM','DD-MON-RR HH.MI.SSXFF AM'),0);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (139,'Isopro',4,to_timestamp('31-DEC-09 11:03:34 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (140,'Jandel Scientific Sigmasuite',4,to_timestamp('31-DEC-09 11:03:39 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (141,'Lean Manufacturing',4,to_timestamp('31-DEC-09 11:03:44 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (142,'Lemmy',4,to_timestamp('31-DEC-09 11:03:50 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (143,'Lingobit Localizer 4.5',4,to_timestamp('31-DEC-09 11:03:55 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (144,'Lview Pro 2.0',4,to_timestamp('31-DEC-09 11:04:01 AM','DD-MON-RR HH.MI.SSXFF AM'),6);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (145,'Mathcad 2000',4,to_timestamp('31-DEC-09 11:04:05 AM','DD-MON-RR HH.MI.SSXFF AM'),9);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (146,'Max+Plus Ii 10.0',4,to_timestamp('31-DEC-09 11:04:10 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (147,'Matlab',4,to_timestamp('31-DEC-09 11:04:15 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (148,'Mcafee Virusscan 7.0 Home Use',4,to_timestamp('31-DEC-09 11:04:19 AM','DD-MON-RR HH.MI.SSXFF AM'),99);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (149,'Mediastudio Pro 7',4,to_timestamp('31-DEC-09 11:04:24 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (150,'Microsoft Office 97 Small Business Edition',3,to_timestamp('31-DEC-09 11:04:54 AM','DD-MON-RR HH.MI.SSXFF AM'),5);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (151,'Microsoft Office 97 Standard',3,to_timestamp('31-DEC-09 11:05:00 AM','DD-MON-RR HH.MI.SSXFF AM'),6);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (152,'Microsoft Office 2000 Standard',3,to_timestamp('31-DEC-09 11:05:44 AM','DD-MON-RR HH.MI.SSXFF AM'),30);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (153,'Microsoft Office Xp Standard',3,to_timestamp('31-DEC-09 11:05:50 AM','DD-MON-RR HH.MI.SSXFF AM'),127);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (154,'Microsoft Office 2003 Standard',3,to_timestamp('31-DEC-09 11:05:54 AM','DD-MON-RR HH.MI.SSXFF AM'),11);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (155,'Microsoft Office 2007 Standard',3,to_timestamp('31-DEC-09 11:06:06 AM','DD-MON-RR HH.MI.SSXFF AM'),56);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (156,'Microsoft Office 2000 Sbe (No Powerpoint)',3,to_timestamp('31-DEC-09 11:06:11 AM','DD-MON-RR HH.MI.SSXFF AM'),26);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (157,'Microsoft Access 2000 (Stand Alone)',3,to_timestamp('31-DEC-09 11:06:16 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (158,'Microsoft Access 2003 (Stand Alone)',3,to_timestamp('31-DEC-09 11:06:21 AM','DD-MON-RR HH.MI.SSXFF AM'),26);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (159,'Microsoft Office Professional & Bookshelf',3,to_timestamp('31-DEC-09 11:06:25 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (243,'Test Complete',4,to_timestamp('31-DEC-09 11:16:22 AM','DD-MON-RR HH.MI.SSXFF AM'),2);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (244,'True Dbgrid Pro 8.0',4,to_timestamp('31-DEC-09 11:16:26 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (245,'T Value 4.0',4,to_timestamp('31-DEC-09 11:16:32 AM','DD-MON-RR HH.MI.SSXFF AM'),3);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (246,'Ulead Gif Animator',4,to_timestamp('31-DEC-09 11:16:38 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (247,'Virtual Pc For Mac & 1 Xp Pro License',4,to_timestamp('31-DEC-09 11:16:44 AM','DD-MON-RR HH.MI.SSXFF AM'),4);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (248,'Visio 4.0 For Windows',4,to_timestamp('31-DEC-09 11:16:54 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (249,'Visual Dialogscript',4,to_timestamp('31-DEC-09 11:17:01 AM','DD-MON-RR HH.MI.SSXFF AM'),5);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (250,'Visual Dialogscriptpro',4,to_timestamp('31-DEC-09 11:17:07 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (251,'Winwedge 3.0C',4,to_timestamp('31-DEC-09 11:17:14 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    Insert into SOFTWARE (SWID,NAME,SWCATID,LAST_UPDATE_DATE,LICCNT) values (252,'Xtools',4,to_timestamp('31-DEC-09 11:17:22 AM','DD-MON-RR HH.MI.SSXFF AM'),1);
    REM INSERTING into SWCAT
    Insert into SWCAT (SWCATID,CATDESC,LAST_UPDATE_DATE) values (1,'OPERATING SYSTEM',to_timestamp('30-DEC-09 02:51:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWCAT (SWCATID,CATDESC,LAST_UPDATE_DATE) values (2,'ADOBE SOFTWARE',to_timestamp('30-DEC-09 02:57:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWCAT (SWCATID,CATDESC,LAST_UPDATE_DATE) values (3,'MICROSOFT SOFTWARE',to_timestamp('30-DEC-09 02:57:00 AM','DD-MON-RR HH.MI.SSXFF AM'));
    Insert into SWCAT (SWCATID,CATDESC,LAST_UPDATE_DATE) values (4,'NONE',to_timestamp('30-DEC-09 02:57:00 AM','DD-MON-RR HH.MI.SSXFF AM'));

  • Need help with sum from previous years

    Hi All,
    In a report i have 4 fields. The first field shows the YTD invoice totals for the current FY 2010 (which i accomplished). The other 3 fields are :
    2nd field Sum of the value of invoices for the FY 1YEAR prior to the current year
    3rd field Sum of the value of invoices for the FY 2YEAR's prior to the current year.
    4th field Sum of the value of invoices for the FY 3YEAR's prior to the current year.
    How can i get the desired results for the second,third and the fourth fields, please need help or advice.
    Thanks

    Hi
    If you have the values for several years in the same report you should be able to do what you want using the analytic LEAD and LAG.
    LAG will retrieve values from previous rows whereas LEAD will retrieve values from following rows.
    The basic syntax is the same and look like this:
    LAG(value, offset) OVER ({optional_partition_clause} ORDER BY mandatory_order_clause)
    The ORDER BY clause is mandatory and cannot be omitted. However, this ORDER BY has nothing to do with the sort order you manually create in the worksheet. Generally, most people will set their sort order the same as the ORDER BY in the calculation.
    Here's an example that gets year to date from 2 financial years ago:
    LAG(YTD,2) OVER (ORDER BY FY)
    You have to understand that Discoverer will pull values from previous rows not from previous cells as displayed on the report, although if the cells may happen to be rows too then it will appear as though it is pulling previous cells. I personally am very experienced with analytuc functions and can make manipulate data within Discoverer just about any way that I want. Generally, if I can see data on the screen even when they are in different cells or rows I can create functions to manipulate it. This capability only comes about as a result of experience and I would strongly advise you to practice with the analytics and see if you can at least master some of them. You'll find your Discoverer capabilities will improve dramatically and you will become a great asset at work.
    When working with a new report I generally duplicate the report as a table so that I can see the values. Then if I need to sort the items in order to line up the values I want to work with I do so. Having worked out what sort order I need I can then see what offset I use then I create the analytic and use it in the main worksheet.
    Hope this helps
    Best wishes
    Michael

  • Actuate to BIP Conversion Need Help with Sum and Distinct

    Hi,
    I am in the process of converting an Actuate report to BI Publisher .rtf format. Within the actuate report I have encountered the following code in one of the fields:
    Sum([ssCalc])Distinct([ssProfessional_Id])
    From what I understand this Actuate code is grouping by distinct ssProfessional_Id then taking the sum of the ssCalc field.
    In my .rtf template I have the following:
    <?for-each-group:ssSRA;./ssCIN?>
    <?ssCalc?>
    <?end for-each-group?>
    I need to convert the Actuate code into the place where I currently have <?ssCalc?> in my template but I have no idea how I can translate translate this. Does anyone have any suggestions?????
    Thanks,
    Fred

    Fred
    Can you post the XML, easier to help then
    Tim

  • Help with summing rows

    I really need some help! I have a form has a lot of rows and columns. I know how to sum them using Formcalc, but it would be tedious and time-consuming to do it again and again for all my fields.
    So, here's kind of how the form looks like:
                                                 January           February       March              .......       Total Year
    Recyclable Amount
    Waste Amount
                                                                                    Total Tons
    What I was doing was something like this: Sum(January[0], February[0]....December[0]) under "Total Year". But I would have to repeat this about 20 times for different rows. Is there a script to easily sum across the row, so I don't have to manually change the numbers in the bracket each row? Thanks! I know this might sound confusing, so let me know if my question isn't clear... Thanks in advance!!

    I really need some help! I have a form has a lot of rows and columns. I know how to sum them using Formcalc, but it would be tedious and time-consuming to do it again and again for all my fields.
    So, here's kind of how the form looks like:
                                                 January           February       March              .......       Total Year
    Recyclable Amount
    Waste Amount
                                                                                    Total Tons
    What I was doing was something like this: Sum(January[0], February[0]....December[0]) under "Total Year". But I would have to repeat this about 20 times for different rows. Is there a script to easily sum across the row, so I don't have to manually change the numbers in the bracket each row? Thanks! I know this might sound confusing, so let me know if my question isn't clear... Thanks in advance!!

  • Need help with summing column when using if-then-else

    Using logic
    <?xdofx:if INVOICE_BILL_AMT_IN_INV_CURR is null then INVPROC_BILL_AMOUNT else INVOICE_BILL_AMT_IN_INV_CURR end if?> for column field.
    Having trouble summing the column using the logic above.
    Any suggestions would be very much appreciated.
    Thanks,
    Nancy

    Thanks Tim,
    That worked. Got rid of my error. However, if the field is null (=''), I get a total.
    11.05 + 1429.70 = 1440.75
    If the not null (!='') I am not getting a total.
    103.74 + 173.13 =
    BTW, recently took XML class. Leta Davis highly recommended your blog and I have gotten a lot of great tips from it.
    Thanks,
    Nancy

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • Help with count and sum query

    Hi I am using oracle 10g. Trying to aggregate duplicate count records. I have so far:
    SELECT 'ST' LEDGER,
    CASE
    WHEN c.Category = 'E' THEN 'Headcount Exempt'
    ELSE 'Headcount Non-Exempt'
    END
    ACCOUNTS,
    CASE WHEN a.COMPANY = 'ZEE' THEN 'OH' ELSE 'NA' END MARKET,
    'MARCH_12' AS PERIOD,
    COUNT (a.empl_id) head_count
    FROM essbase.employee_pubinfo a
    LEFT OUTER JOIN MMS_DIST_COPY b
    ON a.cost_ctr = TRIM (b.bu)
    INNER JOIN MMS_GL_PAY_GROUPS c
    ON a.pay_group = c.group_code
    WHERE a.employee_status IN ('A', 'L', 'P', 'S')
    AND FISCAL_YEAR = '2012'
    AND FISCAL_MONTH = 'MARCH'
    GROUP BY a.company,
    b.district,
    a.cost_ctr,
    c.category,
    a.fiscal_month,
    a.fiscal_year;
    which gives me same rows with different head_counts. I am trying to combine the same rows as a total (one record). Do I use a subquery?

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    user610131 wrote:
    ... which gives me same rows with different head_counts.If they have different head_counts, then the rows are not the same.
    I am trying to combine the same rows as a total (one record). Do I use a subquery?Maybe. It's more likely that you need a different GROUP BY clause, since the GROUP BY clause determines how many rows of output there will be. I'll be able to say more after you post the sample data, results, and explanation.
    You may want both a sub-query and a different GROUP BY clause. For example:
    WITH    got_group_by_columns     AS
         SELECT  a.empl_id
         ,     CASE
                        WHEN  c.category = 'E'
                  THEN  'Headcount Exempt'
                        ELSE  'Headcount Non-Exempt'
                END          AS accounts
         ,       CASE
                        WHEN a.company = 'ZEE'
                        THEN 'OH'
                        ELSE 'NA'
                END          AS market
         FROM              essbase.employee_pubinfo a
         LEFT OUTER JOIN  mms_dist_copy             b  ON   a.cost_ctr     = TRIM (b.bu)
         INNER JOIN       mms_gl_pay_groups        c  ON   a.pay_group      = c.group_code
         WHERE     a.employee_status     IN ('A', 'L', 'P', 'S')
         AND        fiscal_year           = '2012'
         AND        fiscal_month          = 'MARCH'
    SELECT    'ST'               AS ledger
    ,       accounts
    ,       market
    ,       'MARCH_12'          AS period
    ,       COUNT (empl_id)       AS head_count
    FROM       got_group_by_columns
    GROUP BY  accounts
    ,            market
    ;But that's just a wild guess.
    You said you wanted "Help with count and sum". I see the COUNT, but what do you want with SUM? No doubt this will be clearer after you post the sample data and results.
    Edited by: Frank Kulash on Apr 4, 2012 5:31 PM

  • Help with Keywording a group of Images

    I need help applying keywords to a group of selected images. For some reason I can't get this to work. I've done it before and now it won't work. Here is what I'm doing. I've selected a group of images in a project by using shift and clicking the first and last image I want and using comand to select images that are not next to each other. They all show up in the viewer and the thin white lines show up around the images in the browser. Now I go and add a keyword. It doesn't seem to matter if I use the Keyword control bar buttons or if I type in a key word in the bar in the lower right hand side, the same thing happens. The keyword is only being applied to the primary selection and not the whole group. Why isn't this working? I'm sure I'm missing something simple, but it's starting to drive me crazy. Any help with this would be great thanks.
    -Matthew

    You have switched 'toggle primary only' on. To turn it off click on the button with a square in it at the bottom of the screen or press 's'

  • Please Help with group chat probs

    I don't get any sound or vibe notification for my group chats also In my group chats if a pic is posted and then comments made on that pic I can't scroll up or down to see all comments. This is something I need to fix as we use pic with chats at work.  I can't get the info I need.  If any one could help with this problem please do. This problem has only been since I upgraded to the newest bbm messenger last week. I have the Q10. I pulled the battery and sims card but this did nothing to fix the problem. Please if anyone can help!
    Thank you all  

    Please make sure you are using TRUCN() in your GROUP BY expression. This function will truncate the date by removing time content.
    Best of luck!

  • Help with a group query

    I have the following table
    EX_ID
    EX_NAME
    EX_SURNAME
    EX_FLAG
    1
    TOM
    JONES
    Y
    1
    JIM
    SLIM
    N
    1
    BO
    SELECTA
    Y
    2
    AIRES
    BEARS
    N
    2
    JIM
    DAVIES
    Y
    3
    PAUL
    BALL
    N
    3
    YOU
    KNOW
    N
    I need to create a query that only displays one of the ex_id’s, it doesn’t matter which one.  When the query has been run it will look like below:
    EX_ID
    EX_NAME
    EX_SURNAME
    EX_FLAG
    1
    TOM
    JONES
    Y
    2
    AIRES
    BEARS
    N
    3
    YOU
    KNOW
    N
    Can anyone help with this query?

    SELECT * FROM
    SELECT *,ROW_NUMBER () OVER (PARTITION BY ex_id ORDER BY (SELECT 0))
    FROM tbl
    ) AS Der WHERE rn=1
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Need help with NULL values in Crosstables

    Hello everybody,
    I need some help with NULL values and crosstables. My issue is the following:
    I have a query (BW - MDX-Query) that gives me turnover measures for each month. In Crystal Reports I choose crosstable to display this whereby I put all month in columns and all turnover-measures in rows. Each month that has a value (measures are not empty) is chown in the crosstables rows. So far so good. The problem occures when there are month that actually have no values (measures are empty). In that case these months are not chown in columns. But I need CR to display these columns and show the value 0. How can I do that?

    Hi Frank,
    Cross tab shows the data based on your column and these column fields are grouped and based on the group it will show your summaries. 
    If there is no data for any of your group it will not display that group.  In this case you will have to create a standard report which should look like cross tab and to get zero values you need to write formulas .
    Example if you want to display Moth wise sales :
    if Month() = 01 Then
    sum() else 0
    Now this formula will check if your month is Jan, then it will sum up the values else it will display zero value. 
    This is possible only through standard report not with Cross Tab.
    Thanks,
    Sastry

  • Help with triggers

    Hi All,
    i have a few triggers that I need your help with.
    The first trigger (below) is fired when an update is made to a column in an invoices table.
    The question I have is to do with the exception section.
    I want to change the status of the invoice if it fails to F.
    This trigger has already complied fine but I have no test data yet to test against.
    I was unsure of the mutating effect and was wondering if the exception section will cause it to mutate since it is trying to update the status of the current invoice being processed. Pls see below
    create or replace
    TRIGGER POP_STAGE AFTER
    UPDATE OF "EXCHANGED_DATE" ON "INVOICES" FOR EACH ROW
    declare
    -- check if the invoice.mco_transfer_status has been updated to R
    -- if it has then insert records into the relevant tables
    -- Start the Insert based on the update of invoices.mco_transfer_status
    ecode varchar2(100);
    thisproc CONSTANT VARCHAR2(80) := 'trap_errmesg for transfer_status';
    v_value varchar2(150);
    BEGIN
    -- do updates based on update of invoices.transfer_status column
    IF :NEW.TRANSFER_STATUS='R'
    THEN
    -- Insert into E_TICKET_STAGE
    INSERT INTO E_TICKET_STAGE (emco_document_number,exchanged_date,pax_seq,pax_forename,pax_surname,pax_type)
    select :NEW.EMCO_DOCUMENT_NUMBER, :NEW.EXCHANGED_DATE,PX.PAX_SEQ,PX.FORENAME,PX.SURNAME,PX.PAX_TYPE
    FROM PAX PX WHERE PX.BOOKING_ID=:NEW.BOOKING_ID;
    -- Insert into SECTOR_STAGE table
    INSERT INTO SECTOR_STAGE (emco_document_number,ps_id,sector_seq,pax_seq,fare_class,fare_basis,net_fare,tax,gross_fare,
    flight_number,departure_date,dep_airport_code,dest_airport_code)
    SELECT :NEW.EMCO_DOCUMENT_NUMBER, PS.PS_ID,PS.SECTOR_SEQ,PS.PAX_SEQ,PS.FARE_CLASS,PS.FARE_BASIS,PS.NET_FARE,PS.TAX,PS.GROSS_FARE,BS.FLIGHT_NUMBER,BS.DEPARTURE_DATE,
    BS.DEP_AIRPORT_CODE,BS.DEST_AIRPORT_CODE
    FROM PAX_SECTORS PS, BOOKING_SECTORS BS
    WHERE PS.BOOKING_ID=:NEW.BOOKING_ID
    AND BS.BOOKING_ID=PS.BOOKING_ID;
    -- Insert into TAX_STAGE table
    INSERT INTO TAX_STAGE (emco_docUment_number,PS_ID,TAX_SEQ,TAX_CODE,VALUE)
    SELECT :NEW.EMCO_DOCUMENT_NUMBER, pt.PS_ID,TAX_SEQ,TAX_CODE,VALUE
    FROM PAX_TAX pt,PAX_SECTORS ps
    WHERE ps.BOOKING_ID=:OLD.booking_id and pt.PS_ID=ps.PS_ID;
    -- Insert into CHARGES_STAGE table
    insert into CHARGES_STAGE (emco_document_number,CHARGE_TYPE,CHARGE_AMOUNT)
    select :NEW.EMCO_DOCUMENT_NUMBER, CHARGE_TYPE,VALUE FROM INVOICE_DETAILS IND
    WHERE :NEW.INVOICE_ID=IND.INVOICE_ID;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    ecode := SQLCODE|| ' '||sqlerrm ;
    dbms_output.put_line(thisproc || ' - ' || ecode);
    v_value := thisproc || ' - ' || ecode;
    -- Insert into DOCUMENT_STATUS_STAGE ANY ERRORS DURING PROCESSING
         insert into DOCUMENT_STATUS_STAGE (EMCO_DOCUMENT_NUMBER, STATUS,STATUS_DATE)
    VALUES (:NEW.EMCO_DOCUMENT_NUMBER,v_value,sysdate);
    update invoices set TRANSFER_STATUS='F' where invoice_id=:old.invoice_id;
    END pop_stage;
    The second trigger (also below) does a check on the payments table to see if the payment_complete date has been set.
    If this has been set then we want to sum all the payments (based on invoice_id). once this sum has been made we want to compare this value to the value of the gross amount on the invoices table for that invoice. if they match (which shows the invoce has been fully paid) then we want to update the paid_date and set to sysdate.
    create or replace
    TRIGGER CHECK_INVOICE_STATUS AFTER
    UPDATE OF "PAYMENT_COMPLETE" ON "PAYMENTS" FOR EACH ROW
    declare
    -- check if all the payments for that invoice have been received (completed)
    -- if they are complete then sum all the payments for that invoice and compare to gross value on invoices
    v_invoice_amount number;
    v_gross_amount number;
    thisproc CONSTANT VARCHAR2(80) := 'trap_errmesg for mco_transfer_status';
    v_value varchar2(150);
    BEGIN
    IF :NEW.PAYMENT_COMPLETE is not null
    THEN
    -- We will sum all the payments for that invoice that have a value in payment_complete
    select sum(amount) into v_invoice_amount from payments where payment_complete is not null
    group by :OLD.INVOICE_ID;
    -- We will also get the gross amount for the invoice to compare to the sum of the payments
    select gross into v_gross_amount from invoices where
    :OLD.INVOICE_ID = invoice_id;
    END IF;
    IF v_invoice_amount = v_gross_amount
    then
    update invoices set paid_date=sysdate;
    end if;
    end CHECK_INVOICE_STATUS;
    Is this trigger sufficent?
    Any tips will be appreciate.
    Thanks

    I didn't really look into your post (rather long) ... anyway, I have 2 words for you "stored procedures".

Maybe you are looking for

  • Photoshop CS4 crashing on Vista 64-bit

    I downloaded PSCS4GPU_OptionalPlugins.zip from http://kb.adobe.com/selfservice/viewContent.do?externalId=kb405064 It includes Disallow OpenGL Windows and Allow Old GPUS script files that are are also uninstallable. On my machine at work (Windows XP P

  • How i can display Urdu word in JSP

    I want to display unicode of URDU Language using jsp. When i display urdu word then browser display ??? ????? letter. Best Regards Abdul Rehman

  • Some albums not listed under artist.

    Some albums appear in the Albums list but not in the Artist/Album submenu. eg; I have 2 albums by Sigur Ros but only one shows when I go: Artist/Sigur Ros - Album. I only see one. I see both under the Album list. Any thoughts appreciated...

  • Loss of connection when device turned off then back on

    I have an Airport extreme and a base station. The extreme is set in "bridge mode" and the base station extends the network. My router is an ARRIS that hands out the IP address. Everything has been working great for the last year but recently problems

  • BP 6700 fax test all pass but won't recieve a fax

    This BP 6700 did  work very good, but it stopped recieving faxes and i can't seem to get it to work and have no way of testing it for recieving faxes.The fax test shows all  pass. there isn't an icon on the screen to do the fax from the computer. tha