Query to grouping on task priority for each employee

Hi All,
We have following table structure for employee, task & taskallocation.
CREATE TABLE EMP
   (     "EMP_ID" NUMBER(10,0) NOT NULL ENABLE,
          "FNAME"     NVARCHAR2(50) NOT NULL ENABLE,
          "LNAME"     NVARCHAR2(50) NOT NULL ENABLE
CREATE TABLE TASKS
   (     "TASK_ID" NUMBER(10,0) NOT NULL ENABLE,
          "TASK_PRIORITY" NVARCHAR2(10) NOT NULL ENABLE          
CREATE TABLE TASKSALLOCATION
   (     "TASKALLOCATION_ID" NUMBER(10,0) NOT NULL ENABLE,
          "EMP_ID" NUMBER(10,0) NOT NULL ENABLE,
          "TASK_ID" NUMBER(10,0) NOT NULL ENABLE
   The data for the same will be as follows
Insert into EMP (EMP_ID,FNAME,LNAME) values (1,'XYZ','DFD');
Insert into EMP (EMP_ID,FNAME,LNAME) values (2,'DFDS','FD');
Insert into EMP (EMP_ID,FNAME,LNAME) values (3,'FDSF','GFH');
Insert into EMP (EMP_ID,FNAME,LNAME) values (6,'GFHGF','GFHS');
Insert into EMP (EMP_ID,FNAME,LNAME) values (4,'GFD','FDG');
Insert into EMP (EMP_ID,FNAME,LNAME) values (5,'DSFDS','FDSAF');
Insert into EMP (EMP_ID,FNAME,LNAME) values (7,'GHGY','EWE');
Insert into EMP (EMP_ID,FNAME,LNAME) values (8,'FGRFSAD','SADF');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (1,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (2,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (3,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (4,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (5,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (6,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (7,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (8,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (9,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (10,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (11,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (12,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (13,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (14,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (15,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (16,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (17,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (18,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (19,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (20,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (21,'LOW');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (22,'HIGH');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (23,'MEDIUM');
Insert into TASKS (TASK_ID,TASK_PRIORITY) values (24,'LOW');
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (1,1,1);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (2,2,1);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (3,3,2);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (4,3,3);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (5,4,4);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (6,4,5);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (7,4,6);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (8,4,7);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (9,5,6);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (10,6,8);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (11,7,9);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (12,8,8);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (13,8,10);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (14,8,11);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (15,8,12);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (16,6,13);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (17,5,14);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (18,3,12);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (19,3,13);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (20,2,15);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (21,1,16);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (22,2,17);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (23,1,18);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (24,4,19);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (25,6,20);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (26,5,21);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (27,1,22);
Insert into TASKSALLOCATION (TASKALLOCATION_ID,EMP_ID,TASK_ID) values (28,3,23);
COMMIT;And we are looking count of tasks based grouping on it's priority per employee. Something like this,
Resultset
with
    t as
          select     'XYZ DFD' as EMP_NAME,     3 as HIGH ,     0 as MEDIUM,     1 as LOW FROM dual union all
          select     'DFDS FD'     ,     1     ,     1     ,     1     FROM dual union all
          select     'FDSF GFH'     ,     1     ,     2     ,     2     FROM dual union all
          select     'GFHGF GFHS'     ,     3     ,     1     ,     1     FROM dual union all
          select     'GFD FDG'     ,     0     ,     1     ,     2     FROM dual union all
          select     'DSFDS FDSAF'     ,     1     ,     2     ,     0     FROM dual union all
          select     'GHGY EWE'     ,     0     ,     0     ,     1     FROM dual union all
          select     'FGRFSAD SADF'     ,     1     ,     2     ,     1     FROM dual)Note : We are using Oracle 11.2.0.2.0 version

Hi,
select emp.fname || ' ' || emp.lname EMP_NAME
     , sum(case when tasks.TASK_PRIORITY = 'HIGH' then 1 else 0 end) HIGH
     , sum(case when tasks.TASK_PRIORITY = 'MEDIUM' then 1 else 0 end) MEDIUM
     , sum(case when tasks.TASK_PRIORITY = 'LOW' then 1 else 0 end) LOW
  from emp
  join TASKSALLOCATION
    on emp.EMP_ID = TASKSALLOCATION.EMP_ID
  join TASKS
    on TASKSALLOCATION.TASK_ID = tasks.TASK_ID
group by emp.fname || ' ' || emp.lname
EMP_NAME                   HIGH     MEDIUM        LOW
FGRFSAD SADF                  1          2          1
XYZ DFD                       3          0          1
GHGY EWE                      0          0          1
GFHGF GFHS                    1          2          0
GFD FDG                       3          1          1
DFDS FD                       1          1          1
FDSF GFH                      1          2          2
DSFDS FDSAF                   0          1          2Regards
Martin Preiss

Similar Messages

  • Separate task sequence for each language

    i have separate task sequence for each language so it's possible to create report machine name with language specific to collection

    i have separate task sequence for each language
    That will work but it's not considered "best practise" as it can most likely be handled by a single task sequence.
    I don't understand which report you need. Please provide the colums names and where the data should be taken from.
    Torsten Meringer | http://www.mssccmfaq.de

  • Want to print the whole month with or without overtime for each employee

    Hi,
    I have Oracle forms/reports10g R2, Below query returns employee overtime correctly but I want to add the whole month with it in simple words if one employee have overtime for five days in a month I want the query to return the whole month including five overtime days for each employee and let say if we have ten employees query return whole month for each employee either he have or overtime or not how can I implement this in report it becomes agony for me, anyone please suggest a solution.
    Thanks and regards, Khawar.
    ---Query---
    select o.ot_date , o.start_dt_time as start_time, o.end_dt_time as end_time, o.ot_details, et.holiday, et.staff_id, e.staff_name, e.desig
    from overtime o, emp_ot et, employee e
    where o.complain_no = et.complain_no
    and o.inc_type_code = et.inc_type_code
    and et.staff_id = e.staff_id
    order by 1, 2, 3, e.staff_id

    Hi Michael,
    Thanks for reply, I think I didn't explain as I should, I want to print Overtime report for each employee let say employee A123 did overtime for five days in DEC than what I want is to print report for employee A123 for the whole month means when I print report blank cell should come where A123 don't have data (I mean other 25/26 days).
    The structure of tables are as
    SQL> desc overtime
    Name Null? Type
    COMPLAIN_NO NOT NULL NUMBER(5)
    OT_DATE NOT NULL DATE
    START_DT_TIME NOT NULL DATE
    INC_REF_NO NUMBER(5)
    END_DT_TIME NOT NULL DATE
    INC_TYPE_CODE NOT NULL VARCHAR2(10)
    DISTRICT_CODE VARCHAR2(6)
    BUSBAR_VOL VARCHAR2(5)
    OT_DETAILS VARCHAR2(2000)
    SQL> desc EMP_OT
    Name Null? Type
    STAFF_ID NOT NULL VARCHAR2(8)
    COMPLAIN_NO NOT NULL NUMBER(5)
    INC_TYPE_CODE NOT NULL VARCHAR2(10)
    HOLIDAY NUMBER
    Each employee associated with primary key i.e COMPLAIN_NO and INC_TYPE_CODE
    in each OVERTIME table record we may have more than one employee in EMP_OT table.
    above detail may clear my query.
    Thanks and Regards,
    Khawar.

  • For each EMPLOYEE, the Concatenated DESCRIPTION of the employees.

    for each EMPLOYEE (Table IN),
    the Concatenated DESCRIPTION of the employees (Table OUT).
    Table IN:
    EMPLOYEE DESCRIPTION
    Weiss "pay 3$"
    Weiss "pay 1$"
    Weiss "pay 4$"
    De Haan "7$"
    De Haan "8$"
    Table OUT:
    EMPLOYEE ALL_DESCRIPTION
    Weiss "pay 3$pay 1$pay 4$"
    De Haan "7$8$"
    for each EMPLOYEE, the Concatenated DESCRIPTION of the employees.
    How make from table IN -> table OUT?

    I don't know exactly what you mean by Table IN and Table OUT, but the next query will give you a clue:
    SQL> create table table_in
      2  as
      3  select 'Weiss' employee, 'pay 3$' description from dual union all
      4  select 'Weiss', 'pay 1$' from dual union all
      5  select 'Weiss', 'pay 4$' from dual union all
      6  select 'De Haan', '7$' from dual union all
      7  select 'De Haan', '8$' from dual
      8  /
    Tabel is aangemaakt.
    SQL> select employee
      2       , d all_description
      3    from ( select employee
      4                , d
      5                , rn
      6             from table_in
      7            model
      8                  partition by (employee)
      9                  dimension by (row_number() over (partition by employee order by null) rn)
    10                  measures (cast(description as varchar2(100)) d)
    11                  rules
    12                  ( d[any] order by rn desc = d[cv()] || d[cv()+1]
    13                  )
    14         )
    15   where rn = 1
    16  /
    EMPLOYE ALL_DESCRIPTION
    Weiss   pay 1$pay 3$pay 4$
    De Haan 7$8$
    2 rijen zijn geselecteerd.Regards,
    Rob.

  • How can we load apps without creating an Apple ID for each employee?

    We have at least two apps that we'd like to distribute to our company iPads.  We would like to hand the employee the iPad with everything loaded.  We don't care if they create their own Apple ID and manage it after the fact but when the employee gets the iPad, it should have the apps they require.
    How do we load these apps without creating an Apple ID for each employee?  If we load the apps from App Store with our Apple ID, the app requires that username and password whenever there is an update.  The employee can not update the app without our username and password or they have to delete and reinstall the app with their own credentials.  Is there a way to load an app so that it doesn't require the credentials of the person that loaded it whenever there's an update?

    Turn on computer.
    Open itunes.
    Connect a device.
    Select what you want to sync.
    Sync
    Repeat for the otehr device

  • Report for time log on detail for each employees in SAP ABAP-HR report

    hi experts,
          please help me .how to create a report for time log on detail for each employees in SAP ABAP-HR report.please help me.
                                                      thank you

    Hi,
    For Time Management Infotypes , If you want to read the data using macro you need to use the Macro called RP_READ_ALL_TIME_ITY
    Example:
    DATA: BEGDA LIKE P2001-BEGDA, ENDDA LIKE P2001-ENDDA.
       INFOTYPES:  0000, 0001, 0002, ...
                         2001 MODE N, 2002 MODE N, ...
         GET PERNR.
       BEGDA = '19900101'. ENDDA = '19900131'.
       RP_READ_ALL_TIME_ITY BEGDA ENDDA.
       IF PNP-SW-AUTH-SKIPPED-RECORD NE '0'.
          WRITE: / 'Authorization for time data missing'.
          WRITE: / 'for personnel number', PERNR-PERNR. REJECT.
       ENDIF.

  • How to make RECORD for saving multiple rows for each employee..

    Hi,
    How can I create a record for saving multiple rows for each employee... (parent child relationship)
    I have created all required fields, then created a record, and then created a page. in that page i dragged-n-dropped a scroll area on that page and dropped all required fields from record into that scroll-area.
    whats is happening that its saving ONE (the first) record fine, but for the second record its not storing EMPLID for that row..
    Will I have to make some change at RECORD level ?
    OR Will i have to make some configuration in parent component ?

    Hi, the problem is solved. The record will be created in same way. just create more then one keys (allowing to make composite key in DB table)

  • Query on Grouping Tax Base Balances for Italian Report Customer/Vendor List

    Hello Experts,
    We are implementing the new italian report for customer/vendor List as per Note : 1090857 - Customer/Vendor List for Italy:New Legal Requirement (2007)
    This requires a customizing in Table/View V_T007K(Group Tax Base Balances) where we need to group the tax codes.
    Based on what logic is this table required to be maintained and what considerations need to be taken care of when mainting the tax codes for each column.
    Anyone who has maintained this table or who is ware of the procedure and logic of maintainance , could kindly advise on the same.
    Points would be awarded for any helpful answer.
    Thanks & Regards,
    Rajeshwari

    Hello,
    Thanks for your answer,
    On what basis should the grouping be done.
    Is it only based on the tax codes types?
    or is there any specific rule.
    has anyone maintained this grouping for a Italian company code before?
    Points would be awarded immediately for any help in this.
    Thanks & Warm Regards,
    Rajeshwari

  • Publishing an iCal group with different options for each calendar

    I work at a University and I've my various functions organized into their own calendar; I've a Office calendar for my office activities, a Class calendar for my class activities, a Club calendar for my club activities, and of course a personal calendar. The personal calendar is not published.
    As a general rule, the folks from each fuction know to go to the calendar I've published for them to keep track of their activities. But they also need to see when I'm available, and for that they need to see my entire calendar.
    They need to see what activity I'm engaged in because some of the time I've blocked out is inflexible - class times for example, or departmental meetings - so they know those times are unavailable; but some of the time I've blocked out is relatively flexible - like when I'm listed as being in the office working on a project.
    I can publish them all as a group, but there is one universal setting as to whether each calendar in the group shows details or not. Is there a way to customize what is shown for each calendar in the group? Basically, I don't want the details of my personal calendar published with the rest, but they need to see that I have that time blocked out for something so they know I'm not available. If I don't publish my personal calendar, gaps show up on the grouped calendar that really is not there - it's not time available for someone to schedule an activity.
    And one other question - is there a setting that preserves the colors of the various calendars when published? Right now they all show up as one color. It would help each group if they could scan the complete calendar for their activities.

    Hi K.
          I don't think it's possible to have those text properties vary in a text-ring, but you might be able to accomplish your goal using a pict-ring - using images of formatted text.  In the example (attached) Paint was used to create the pictures then import them into the pict-ring.  Here Unclebump shows how to use "Draw Text at Point.vi" to create formatted text in a picture control, though, I have no idea how to copy such pictures out of the pictures control!
    Cheers!
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
    Attachments:
    FormattedTextPicRing.vi ‏14 KB

  • Running Quickpay from Backend for each employee

    Hi ,
    We have a requirement to submit quickpay from backend for 100 employees.If any one has done same requirement , please send me any sample code please.
    Thanks
    Suhasini.

    We have a requirement to submit quickpay from backend for 100 employees.If any one has done same requirement , please send me any sample code please.I can see users can ask for different requirements. But you can suggest them the best approach for a solution. Why you can not create an assignment set and process hundred employees. Why do you want to schedule Only Quick Pay.

  • Query to find all workbooks/worksheets for each business area

    Hi Experts,
    I need to find all workbooks/worksheets in each business area. Collect 'Query Statistics is checked for all the users'
    Also are there any documents or information available of the description of the discoverer metadata database tables which will help in writing queries
    thanks and regards,
    John

    There is no workbook/worksheet linkage to a business area. So you cannot search for a business area and find all the workbooks "attached" to that business area. The attachment of workbooks is at the folder level. It is actually possible, if you are sharing folders among business areas, to create a workbook with data from 2 or more business areas. I have tested that and it is indeed possible. In Discoverer Administrator you can check on folder dependencies to see what workbooks use the folder. Though in my version of Discoverer, there is a problem with Discoverer Plus, such that the workbook save in Plus is not creating this dependency information like it should. At least I have not found any way to take a business area and determine what workbooks would fall under it. Maybe someone else has found a way.
    John Dickey

  • SQL query to find out last login for each database

    Hi everybody,
    I have a view with following columns:
    DatabaseSid, lastLogin, firstLogin.
    I want to now the newest last_login date for every database.
    SID First Login Last Login
    e.g. Database1, 11.11.2011, 01.12.2011
    Database1, 01.04.2012, 01.05.2012
    Database3, 03.03.2004, 03.06.2005
    Database 3 07.09.2012, 12.10.2012
    How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
    Thank you in advance
    Steve

    Steve wrote:
    Hi everybody,
    I have a view with following columns:
    DatabaseSid, lastLogin, firstLogin.
    I want to now the newest last_login date for every database.
    SID First Login Last Login
    e.g. Database1, 11.11.2011, 01.12.2011
    Database1, 01.04.2012, 01.05.2012
    Database3, 03.03.2004, 03.06.2005
    Database 3 07.09.2012, 12.10.2012
    How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
    Thank you in advance
    SteveI'm curious as to how you collect this information from multiple databases into one database, and of what value the data is once you have it.

  • Query to retrieve latest five transactions for each account

    hi,
    I have a table containing transactions of all account holders (this table contains thousands of records). My requirement is to retrieve recent five transactions from the table for all the account holders. Can anyone help me to retrieve the required data.
    Note: Each account holder may have more than one account e.g. savings account, current account etc.
    Regards,
    N Madhavan

    Hi,
    try something like
    select * from (select row_number() over (partition by holders order by transaction_date desc) r, t.* from t) where r<6;
    HTH
    Laurent Schneider
    OCM DBA

  • Access Parameter Query by form, returns a form for each returned value

    I have a form set up with a parameter query. It returns data from multiple tables. My problem is it returns the data for say 7 records, but then it repeats the entire form 7 times, the forms are identical with all the data included. I want it to return
    the data on one form. It must be a setting, or statement that is lacking but I can't seem to find it.

    Hans,
    Thank You for the response. I first changed the setting in the SubForm Query, same result. Then I changed it in the Report, still no difference. After reading some information in other forums it may be because I am pulling the data from the Tables using
    the InvoiceNum field from one table, on both the Report and the SubForm, and I have the Report and Subform linked by this field. The InvoiceNum field is the Foreign key created to pull the desired data, if I don't use it I get all the data in the tables, not
    just the data I need.

  • Query for aggregates for each date in a date range

    Hi,
    I want to generate a Trend report with a T-SQL proc, which needs following logic. 
    Input -
    Date Range say '10/10/12' to '20/10/12'  (Say to check the trend of Size of account in 20 days of Trend report)
    Account balance is captured randomly, (i mean not every day) 
    Table with date looks like this..
    --Account Balance Table
    CREATE TABLE AccBanalce (
    BranchId SMALLINT
    NOT NULL,
    AccId CHAR(9)
    NOT NULL,
    Amount DECIMAL(9,3)
    NOT NULL,
    SnapShotDate DATETIME
    NOT NULL 
    CONSTRAINT PK_AccBanalce PRIMARY KEY NONCLUSTERED (AccId, SnapShotDate) )
    GO
    Create CLUSTERED INDEX CIx_AccBanalce ON AccBanalce (SnapShotDate)
    GO
    --Date Range table
    CREATE TABLE DateRange ( StartDate DATETIME, EndDate DATETIME)
    GO
    --Date for the Account Balance Table
    INSERT INTO AccBanalce (BranchId, AccId, Amount, SnapShotDate)
    VALUES (1, 'C1-100',  10.4, '10/11/2010' ),
    (1, 'G1-110',  20.5, '10/11/2010' ),
    (2, 'GC-120',  23.7, '10/11/2010' ),
    (2, 'Gk-130',  78.9, '10/13/2010' ),
    (3, 'GH-150',  23.5, '10/14/2010'),
    (1, 'C1-100',  31.8, '10/16/2010' ),
    (1, 'G1-110',  54.8, '10/16/2010' ),
    (2, 'GC-120',  99.0, '10/16/2010' ),
    (3, 'Gk-130',  110.0, '10/16/2010' ),
    (3, 'G5-140',  102.8, '10/16/2010' ),
    (2, 'GC-120',  105,  '10/18/2010' ),
    (2, 'Gk-130',  56.7, '10/18/2010' ),
    (1, 'C1-100',  84.3, '10/18/2010' ),
    (1, 'G1-110',  75.2, '10/19/2010' ),
    (2, 'GC-120',  64.9, '10/20/2010' ),
    (3, 'GH-150',  84.0, '10/20/2010' ),
    (1, 'C1-100',  78.0, '10/20/2010' ),
    (1, 'G1-110',  89.5, '10/20/2010' )
    GO
    --Date for DateRange Table
    INSERT INTO DateRange (StartDate, EndDate) VALUES
    ('2010-10-11 00:00:00.000', '2010-10-11 23:59:59.997'),
    ('2010-10-12 00:00:00.000', '2010-10-12 23:59:59.997'),
    ('2010-10-13 00:00:00.000', '2010-10-13 23:59:59.997'),
    ('2010-10-14 00:00:00.000', '2010-10-14 23:59:59.997'),
    ('2010-10-15 00:00:00.000', '2010-10-15 23:59:59.997'),
    ('2010-10-16 00:00:00.000', '2010-10-16 23:59:59.997'),
    ('2010-10-17 00:00:00.000', '2010-10-17 23:59:59.997'),
    ('2010-10-18 00:00:00.000', '2010-10-18 23:59:59.997'),
    ('2010-10-19 00:00:00.000', '2010-10-19 23:59:59.997'),
    ('2010-10-20 00:00:00.000', '2010-10-20 23:59:59.997')
    GO
    Question - 
    I want TOTAL Balance of all Accounts in a Branch per each day between 10/11/2010 to 10/20/2010
    If the Snapshotdate (date) on which the account was not made an entery to AccBalance table, last available  balance to be considered for that account.
    like for account [C1-100] on 10/15/2010 the balance should be [10.4]
    --Group By Branch
    --Last valid Account balance to be considered.
    I know, this is long solution, but any one who is expert in T-SQL can help me in this solution.
    Thanks,
    Krishna

    Thanks Himanshu You almost solved my issue...but can you provide the final output as following...
    Actually you are aggregating the Amount, which is not required, as it is the total available in that account.
    But the missing pint is I need the SUM of all the accounts for each DAY in a BRANCH.
    The 3rd Result Query modified to get DAILY balances for each account as following...
    --*RESULT*
    SELECT a.AccId, a.StartDate, 
                        (SELECT TOP 1 b.Amount
                        FROM #InterimOutput b
                        WHERE b.AccId = a.AccId and b.Amount > 0
                        AND B.StartDate<=A.StartDate  ORDER BY B.StartDate DESC) as ToDateBal
    FROM   #InterimOutput a
    ORDER BY a.AccId
    go
    Now I need SUM of all Account Balances AT each BRANCH on DAILY basics. Can you help on that?
    Thanks again
    Krishna

Maybe you are looking for

  • How do i change my icloud account on my iphone and ipad?

    How do I change my ic;oud account on my iphone and ipad??

  • Backup/Distribute Adobe Reader 9.4 Toolbar

    I'm currently distributing Adobe Reader 9.4 via SCCM. I would like to know how to backup and distribute the settings for the toolbar. Specifically, I need to add the save, email, first page and last page buttons for all my users. If I can't backup a

  • How to move ab object ?

    hello everybody I made a simple wooden car object in 3d studio, exported it to ASE file and loaded to the scene using ASE loader http://img82.imageshack.us/img82/3306/samochodfv8.jpg thats the beauty =) now, I would like to move him using KeyNavigato

  • Windows Journal Keeps Crashing

    Just today my windows journal keeps crashing.  Every time I launch the software it stops responding immidiately.  I also can't use the windows journal printer.  Both of these functionalities are crucial to my use of my new computer.  I have a brand n

  • Indesign Spell Check plugin?

    Hi all, Have browsed the web a bit but haven't come across quite what I'm after. I'm looking for a spell check plugin for InDesign CS6 that gives a little more flexibility over what it's searching for. I want to be able to customize the search. For i