Removing (blank) from Pivot Tables Populated from Data Connection

It took me a long while to fix this one (and a long time to search, because it's a funny one to try to use boolean logic for) and I thought I would share because I've seen a score of folks out there looking for this.
If you have a pivot table with blank values in the row/column area instead of values, Excel automatically populates the cell with (blank).  The word blank shows up in any cell that doesn't have a value, but what if you don't want all those ugly (blank)
values showing up in your report?
If you're pulling the data from an outside source, like a SQL server (in my case from the Project Server Reporting database) then you can't just change the source data, so you seem pretty stuck.
My coworker and I came up with the following fix:
Select the entire sheet.  Use conditional formatting to find all cells that contain the text (blank).  Then for the format, go to "Number" and "Custom".  In the custom field, enter ;;;.  Apply the conditional formatting and those pesky
(blank) values turn into real blanks.  This even works when copying pasting the data into another sheet or application.  And if the value changes the next time you refresh your data, the new data appears.
I found this very valuable in my reporting and just wanted to put it out there for the rest of the community.

Hi,
Thank you for sharing your experience and post here.

Similar Messages

  • How to display the column into the narrative or section from pivot table

    I have a report. I have the basic number displayed in the pivot table, but missing one column and I need move one column to the top. The column missing (% of tested) should be calculated by column c /column F's last number, ie, F7=48. My desired column would be H3=c3/F48 9/48, H4=c4/F488/48.... But I could not get the number 48 into my formula, because it is the running total of the all column E. These data is in Pivot table.
    I also need display No of Students 74 in the top of the report. I am not able to get this number from pivot table. It is count distinct on student key from the repository.
    I appreciate any help.
    A     B     C     D     E     F     G
    2          # of Questions     Average # Correct     % Correct     Running total no. of test items     No of students
    3     PATTERNS, FUNCTIONS, AND ALGEBRA     9     4.68     51.95     9     74
    4     PROBABILITY AND STATISTICS     8     3.97     49.66     17     74
    5     MEASUREMENT AND GEOMETRY     11     6.11     55.53     28     74
    6     NUMBER AND NUMBER SENSE     8     4.16     52.03     36     74
    7     COMPUTATION AND ESTIMATION     12     8.2     68.36     48     74
    Edited by: user7315022 on Feb 3, 2010 2:28 PM

    I wish it was this easy. I must not explain it right. All the score from each student and each question for each subject and each test is stored in database. The number of question for the subject is the max of the questions for each subject. Basically, it needs 'parittion by'... But in the OBIEE, it would not let me add any 'partition by' in the column formula. Is this true? ie, can you use partition by in the column formula? Here are the query from trace file.
    RqList
    TEST_YEAR_SEASONS.TEST_SEASON_NAME as c1 GB,
    REPORTING_SCHOOL_YEARS.SCHOOL_YEAR as c2 GB,
    MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c3 GB,
    STUDENT_TEST_SCORES.TEST_SCORE_NUMBER as c4 GB,
    DIVISION_TOTAL_TESTS:[DAggr(STUDENT_TEST_SCORES.DIVISION_TOTAL_TESTS by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c5 GB,
    RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME as c6 GB,
    RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME as c7 GB,
    TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME as c8 GB,
    SCHOOLS.SCHOOL_NAME as c9 GB,
    SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c10 GB,
    SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] / nullif( COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] , 0) as c11 GB,
    MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] as c12 GB,
    (SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] / nullif( COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] , 0)) / nullif( MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY, STUDENT_TEST_SCORES.STUDENTS_KEY, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME, SCHOOLS.SCHOOL_NAME, STUDENT_TEST_SCORES.TEST_SCORE_NUMBER] )] , 0) * 100 as c13 GB,
    STUDENT_TEST_SCORES.STDNT_STNDRD_TEST_KEY as c14 GB,
    STUDENT_TEST_SCORES.STUDENTS_KEY as c15 GB,
    max(SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) / nullif( max(COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) , 0) as c16 GB,
    (max(SUM_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.SUM_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) / nullif( max(COUNT_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.COUNT_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) , 0)) / nullif( max(MAX_TEST_SCORE:[DAggr(STUDENT_TEST_SCORES.MAX_TEST_SCORE by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] )] by [ REPORTING_SCHOOL_YEARS.SCHOOL_YEAR, TEST_YEAR_SEASONS.TEST_SEASON_NAME, RPT_TEST_DEFINITIONS.TEST_SUBJECT_NAME, RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME, SCHOOLS.SCHOOL_NAME] at_distinct [ ] ) , 0) * 100 as c17 GB
    DetailFilter: RPT_TEST_DEFINITIONS.TEST_LEVEL_NAME = 'GRADE 5' and SCHOOLS.SCHOOL_NAME = 'GLASGOW MIDDLE' and TEST_SCORE_TYPES.TEST_SCORE_TYPE_NAME = 'RAW SCORE' and TEST_YEAR_SEASONS.TEST_SEASON_NAME = 'SPRING' and REPORTING_SCHOOL_YEARS.SCHOOL_YEAR = '200102' and TESTS.TEST_ID = 'SOL' and TEST_DEFINITIONS.PARENT_TEST_SUBJECT_NAME = 'MATHEMATICS' and STUDENT_TEST_SCORES.TEST_SCORE_NUMBER < 900
    OrderBy: c1 asc, c2 asc, c4 asc, c6 asc, c7 asc, c8 asc, c9 asc, c14 asc, c15 asc
    +++azadams:320000:32001b:----2010/02/03 16:48:36
    -------------------- Sending query to database named tacdev (id: <<51109>>):
    select distinct D1.c5 as c1,
    D1.c4 as c2,
    D1.c9 as c3,
    D1.c14 as c4,
    D1.c12 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c15 as c8,
    D1.c8 as c9,
    D1.c11 as c10,
    D1.c11 / decode(D1.c10 , 0 , to_number(null), D1.c10) as c11,
    D1.c9 as c12,
    (D1.c11 / decode(D1.c10 , 0 , to_number(null), D1.c10)) / decode(D1.c9 , 0 , to_number(null), D1.c9) * 100 as c13,
    D1.c13 as c14,
    D1.c16 as c15,
    D1.c3 / decode(D1.c2 , 0 , to_number(null), D1.c2) as c16,
    (D1.c3 / decode(D1.c2 , 0 , to_number(null), D1.c2)) / decode(D1.c1 , 0 , to_number(null), D1.c1) * 100 as c17
    from
    (select max(D1.c1) over (partition by D1.c4, D1.c5, D1.c6, D1.c7, D1.c8) as c1,
    sum(D1.c2) over (partition by D1.c4, D1.c5, D1.c6, D1.c7, D1.c8) as c2,
    sum(D1.c3) over (partition by D1.c4, D1.c5, D1.c6, D1.c7, D1.c8) as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c8 as c8,
    max(D1.c1) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c9,
    sum(D1.c2) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c10,
    sum(D1.c3) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c11,
    sum(D1.c12) over (partition by D1.c4, D1.c16, D1.c5, D1.c13, D1.c6, D1.c7, D1.c15, D1.c8) as c12,
    D1.c13 as c13,
    D1.c14 as c14,
    D1.c15 as c15,
    D1.c16 as c16
    from
    (select max(T56699.TEST_SCORE_NUMBER) as c1,
    count(T56699.TEST_SCORE_NUMBER) as c2,
    sum(T56699.TEST_SCORE_NUMBER) as c3,
    T33435.SCHOOL_YEAR as c4,
    T34232.TEST_SEASON_NAME as c5,
    T52429.TEST_SUBJECT_NAME as c6,
    T52429.TEST_LEVEL_NAME as c7,
    T59709.SCHOOL_NAME as c8,
    count(T36922.STDNT_STNDRD_TEST_KEY) as c12,
    T36922.STDNT_STNDRD_TEST_KEY as c13,
    T56699.TEST_SCORE_NUMBER as c14,
    T56693.TEST_SCORE_TYPE_NAME as c15,
    T36922.STUDENTS_KEY as c16
    from
    SCHOOLS T59709,
    TEST_DEFINITIONS T58733,
    TEST_SCORE_TYPES T56693,
    RPT_TEST_DEFINITIONS T52429,
    TEST_YEAR_SEASONS T34232,
    REPORTING_SCHOOL_YEARS T33435,
    TESTS T34149,
    DETAIL_TEST_SCORES T33341,
    STUDENT_STANDARD_TEST T36922,
    TEST_SCORES T56699
    where ( T33341.TEST_SCORE_TYPES_KEY = T56693.TEST_SCORE_TYPES_KEY and T36922.ADMIN_SCHOOLS_KEY = T59709.SCHOOLS_KEY and T34232.TEST_YEAR_SEASONS_KEY = T36922.TEST_YEAR_SEASONS_KEY and T33435.REPORTING_SCHOOL_YEARS_KEY = T36922.REPORTING_SCHOOL_YEARS_KEY and T34149.TESTS_KEY = T36922.TESTS_KEY and T36922.TEST_DEFINITIONS_KEY = T58733.TEST_DEFINITIONS_KEY and T33341.STDNT_STNDRD_TEST_KEY = T36922.STDNT_STNDRD_TEST_KEY and T33341.TEST_SCORES_KEY = T56699.TEST_SCORES_KEY and T33435.SCHOOL_YEAR = '200102' and T34149.TEST_ID = 'SOL' and T34232.TEST_SEASON_NAME = 'SPRING' and T36922.RPT_TEST_DEFINITIONS_KEY = T52429.RPT_TEST_DEFINITIONS_KEY and T52429.TEST_LEVEL_NAME = 'GRADE 5' and T56693.TEST_SCORE_TYPE_NAME = 'RAW SCORE' and T58733.PARENT_TEST_SUBJECT_NAME = 'MATHEMATICS' and T59709.SCHOOL_NAME = 'GLASGOW MIDDLE' and T56699.TEST_SCORE_NUMBER < 900 )
    group by T33435.SCHOOL_YEAR, T34232.TEST_SEASON_NAME, T36922.STDNT_STNDRD_TEST_KEY, T36922.STUDENTS_KEY, T52429.TEST_SUBJECT_NAME, T52429.TEST_LEVEL_NAME, T56693.TEST_SCORE_TYPE_NAME, T56699.TEST_SCORE_NUMBER, T59709.SCHOOL_NAME
    ) D1
    ) D1

  • How to select data from a table using a date field in the where condition?

    How to select data from a table using a date field in the where condition?
    For eg:
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
                                                      and bdatu = '31129999'.
    thanks.

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

  • How to compare two rows from two table with different data

    how to compare two rows from two table with different data
    e.g.
    Table 1
    ID   DESC
    1     aaa
    2     bbb
    3     ccc
    Table 2
    ID   DESC
    1     aaa
    2     xxx
    3     ccc
    Result
    2

    Create
    table tab1(ID
    int ,DE char(10))
    Create
    table tab2(ID
    int ,DE char(10))
    Insert
    into tab1 Values
    (1,'aaa')
    Insert
    into tab1  Values
    (2,'bbb')
    Insert
    into tab1 Values(3,'ccc')
    Insert
    into tab1 Values(4,'dfe')
    Insert
    into tab2 Values
    (1,'aaa')
    Insert
    into tab2  Values
    (2,'xx')
    Insert
    into tab2 Values(3,'ccc')
    Insert
    into tab2 Values(6,'wdr')
    SELECT 
    tab1.ID,tab2.ID
    As T2 from tab1
    FULL
    join tab2 on tab1.ID
    = tab2.ID  
    WHERE
    BINARY_CHECKSUM(tab1.ID,tab1.DE)
    <> BINARY_CHECKSUM(tab2.ID,tab2.DE)
    OR tab1.ID
    IS NULL
    OR 
    tab2.ID IS
    NULL
    ID column considered as a primary Key
    Apart from different record,Above query populate missing record in both tables.
    Result Set
    ID ID 
    2  2
    4 NULL
    NULL 6
    ganeshk

  • How to get pivot table by using dates

    Hi,
    How to get pivot table by using dates in column.
    Below is the sample table and its value is given.
    create table sample1
    Order_DATE       DATE,
    order_CODE       NUMBER,
    Order_COUNT   NUMBER
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),1,232);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),2,935);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),3,43);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),4,5713);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('30-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),5,11346);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),1,368);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),2,1380);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),3,133);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),4,7109);
    Insert into sample1 (Order_DATE,order_CODE,Order_COUNT) values (to_timestamp('29-SEP-12','DD-MON-RR HH.MI.SSXFF AM'),5,14336);
    select * from sample1;So how to get the data like below.
              order_date
    order_code 30-sep-12 29-sep-12
    1 232 368
    2 935 1380
    3 43 133
    4 5713 7109
    5 11345 14336

    Using the extra data I inserted in my previous reply:select ORDER_CODE,
    SUM(DECODE(extract (month from ORDER_DATE),1,ORDER_COUNT,0)) JAN,
    SUM(DECODE(extract (month from ORDER_DATE),2,ORDER_COUNT,0)) FEB,
    SUM(DECODE(extract (month from ORDER_DATE),3,ORDER_COUNT,0)) MAR,
    SUM(DECODE(extract (month from ORDER_DATE),4,ORDER_COUNT,0)) APR,
    SUM(DECODE(extract (month from ORDER_DATE),5,ORDER_COUNT,0)) MAY,
    SUM(DECODE(extract (month from ORDER_DATE),6,ORDER_COUNT,0)) JUN,
    SUM(DECODE(extract (month from ORDER_DATE),7,ORDER_COUNT,0)) JUL,
    SUM(DECODE(extract (month from ORDER_DATE),8,ORDER_COUNT,0)) AUG,
    SUM(DECODE(extract (month from ORDER_DATE),9,ORDER_COUNT,0)) SEP,
    SUM(DECODE(extract (month from ORDER_DATE),10,ORDER_COUNT,0)) OCT,
    SUM(DECODE(extract (month from ORDER_DATE),11,ORDER_COUNT,0)) NOV,
    SUM(DECODE(extract (month from ORDER_DATE),12,ORDER_COUNT,0)) DEC
    from SAMPLE1
    where trunc(order_date, 'YY') = trunc(sysdate, 'YY')
    group by order_code
    order by order_code;
    ORDER_CODE JAN FEB MAR APR MAY JUN JUL AUG   SEP   OCT NOV DEC
             1   0   0   0   0   0   0   0   0   600   600   0   0
             2   0   0   0   0   0   0   0   0  2315  2315   0   0
             3   0   0   0   0   0   0   0   0   176   176   0   0
             4   0   0   0   0   0   0   0   0 12822 12822   0   0
             5   0   0   0   0   0   0   0   0 25682 25682   0   0Now a bit of explanation.
    1) Whenever you pivot rows to columns, no matter what version of Oracle and no matter what method you use, you have to decide in advance how many columns you are going to have and what the names of the columns are. This is a requirement of the SQL standard.
    2) I use the WHERE clause to get just the data for this year
    3) With EXTRACT, I get just the month without the year.
    4) Using DECODE, I put every month's data into the correct column
    5) Once I do all that, I can just GROUP BY order_code while SUMming all the data for each month.

  • Need to fetch value from a table based on data range

    Hello there,
    I was hoping that the community could give me a hand with this little puzzle I got.
    I am currently creating a Time Dimension for a data wharehouse, and I have the requirement to populate a column named SEASON (e.g: Summer, Winter, Spring, Autumn) for each date row. So for the 20/Dec/2013, the Season column must say Winter.
    Here is now my Time Dimension table looks like, without the Season information (which I yet have to load):
    DimTime Table
    TIMEID
    FULLDATE
    YEAR
    SEASON
    MONTH
    MONTHDAY
    WEEK
    WEEKDAY
    274
    02-MAR-10
    2010
    3
    2
    9
    2
    275
    03-MAR-10
    2010
    3
    3
    9
    3
    276
    04-MAR-10
    2010
    3
    4
    9
    4
    277
    05-MAR-10
    2010
    3
    5
    9
    5
    278
    06-MAR-10
    2010
    3
    6
    9
    6
    279
    07-MAR-10
    2010
    3
    7
    9
    7
    This entire table is being populated using Oracle functions to manipulate a date field from another table, named PDATE:
    My ETL Code
    INSERT INTO DimTime(timeid, fulldate, year, month, monthday, week, weekday)
    SELECT tim_seq.NEXTVAL, pdate, year, month, monthday, week, weekday
    FROM (SELECT DISTINCT pdate, EXTRACT(year from pdate) year, EXTRACT(month from pdate) month,
    EXTRACT(day FROM pdate) monthday, to_number(to_char(to_date(pdate,'DD/MM/YY'),'IW')) week,
    TO_CHAR(pdate, 'D') weekday
    FROM Performance PER
    ORDER BY pdate);
    NOTE: Code considers the table DimTime to be truncated every time it loads (i.e.: I don't need to consider additional loads).
    As you can see, Season wasn't populated. Since the solstices and equinoxes vary for each year, I can't just say that Summer start at a given date (e.g: 21 of June) because one year it could be the 19/Jun, another the 22/Jun, etc. So in order to solve this problem, I have a table named Season which defines the START and END dates for the seasons:
    Season Table
    SEASON#
    SEASONNAME
    YEAR
    DATEFROM
    DATETO
    1
    Spring
    2010
    01-MAR-10
    30-MAY-10
    2
    Summer
    2010
    31-MAY-10
    29-AUG-10
    3
    Autumn
    2010
    30-AUG-10
    28-NOV-10
    4
    Winter
    2010
    29-NOV-10
    27-FEB-11
    5
    Spring
    2011
    28-FEB-11
    29-MAY-11
    6
    Summer
    2011
    30-MAY-11
    28-AUG-11
    7
    Autumn
    2011
    29-AUG-11
    27-NOV-11
    8
    Winter
    2011
    28-NOV-11
    26-FEB-12
    9
    Winter
    2009
    30-NOV-09
    28-FEB-10
    This is the bit I don't know how to do. How can I make sure that I populate the correct Season in my DimTime table based on the season specified in the Season table?
    Thanks in advance for your help!
    Regards,
    P.

    Just join to table Season:
    INSERT
      INTO DimTime(
                   timeid,
                   fulldate,
                   year,
                   month,
                   monthday,
                   week,
                   weekday,
                   seasonname
      SELECT  tim_seq.NEXTVAL,
              pdate,
              year,
              month,
              monthday,
              week,
              weekday
        FROM  (
               SELECT  DISTINCT pdate,
                                EXTRACT(year from pdate) year,
                                EXTRACT(month from pdate) month,
                                EXTRACT(day FROM pdate) monthday,
                                to_number(to_char(to_date(pdate,'DD/MM/YY'),'IW')) week,
                                TO_CHAR(pdate,'D') weekday,
                                seasonname
                 FROM  Performance PER,
                       season
                 WHERE pdate between datefrom and dateto
    SY.

  • How to make a table of annual data from a table of quarterly data?

    I've got a table of quarterly data. I'd like to create a table of annual data, where each cell has the sum of the four cells for the four quarters that make up a calendar year.
    I can do this by pasting a formula into every 4th cell of a second column, but I'd really like a way that doesn't require so many paste operations. Also, when I try doing the same thing into a column that doesn't leave three blank cells, I don't get the annual totals I want (the totaling just moves down one cell, rather than four).
    Two related questions:
    Is there anyway to move my data so that the four quarters appear side-by-side in 4 columns? (Then the annualizing would be easy.)
    Is there any way to take every 4th element from a column and put it somewhere?

    pmbrewer
    I'm having trouble picturing what you have. Correct me if I'm wrong, but I see a single column blocked off in groups of 4 cells. You don't mention them, but you must have additional columns with some sort of identifiers including quarter numbers and items? With this picture in mind let's go to your questions.
    pmbrewer wrote:
    I've got a table of quarterly data. I'd like to create a table of annual data, where each cell has the sum of the four cells for the four quarters that make up a calendar year.
    I can do this by pasting a formula into every 4th cell of a second column, but I'd really like a way that doesn't require so many paste operations.
    This can be done but you're right, it's awkward and can be handled better as you suggest in the first question below.
    Also, when I try doing the same thing into a column that doesn't leave three blank cells, I don't get the annual totals I want (the totaling just moves down one cell, rather than four).
    Can you explain this more clearly? Perhaps give an example?
    Two related questions:
    Is there anyway to move my data so that the four quarters appear side-by-side in 4 columns? (Then the annualizing would be easy.)
    This can be done and you're right, it's easier. How much data has to be moved?
    Is there any way to take every 4th element from a column and put it somewhere?
    What do you mean by this?
    I'm sure members of the forum will be able to help you with a better understanding of your problem. Ultimately I see a table looking something like below:
    pw

  • Simple Query Failure? from 2 tables: pull First [DATE] Where [OIL] 0

    I am a novice Access 2010 user, and I do not know how to write VBA code.  I have written many queries, some built upon others and packaged them into macros, but that's about the extent of my experience, to date. 
    My problem.  I built a query from 2 tables: [AC_PROPERTY] and [AC_PRODUCT]
    I have linked the tables by PROPNUM.  Designed the query to give me every PROPNUM in the db, then give me the 'First' [DATE] 'Where' [OIL] is >0.
    When I run the query with 1 PROPNUM qualified, it works brilliant.  Every case I check is working, on a one-PROPNUM-at-a-time basis.  As soon as I remove the PROPNUM from criteria, so it will pull all PROPNUMs in the db, it appear to work -- that
    is, until you check the data.
    For some reason, it's not consistently picking the correct First date where Oil >0.  I cannot figure out why it's working on some and not on others.  I thought it was a date format problem, but haven't been able to determine or solve the issue.
    I have always (historically) figured out my query problems, but this one has me stumped!  Help!?
    thank you :-)

    I have linked the tables by PROPNUM.  Designed the query to give me every PROPNUM in the db, then give me the 'First' [DATE] 'Where' [OIL] is >0.
    The problem is that FIRST will not always give you the oldest date. Access uses FIRST to get the first record it finds, not the earliest date.
    Use MIN to find oldest date.
    Build a little, test a little

  • Selecting from Multiple Tables but requiring data to match from a 3rd table

    Hello Everyone,
    I'm having alot of trouble with this select
    I have three tables:
    prod_poured, conc_test, and cyl_breakTo put together my report, I need to grab this data:
    cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"and I need it to grab all data in those two tables when one column in the prod_poured table meets a certain condition
    This is what I have so far:
    select cyl_break.pour_no "Pour Number", cyl_break.cyl_id "Cylinder ID", cyl_break.pour_d "Pour Date", conc_test.mix "Mix #", conc_test.amb_t "Ambient Temperature", conc_test.conc_t "Concrete Temperature", conc_test.air "Air %", cyl_break.break_d "Break Date", cyl_break.age "Age (Days)", cyl_break.spec_str "Specified Strength", cyl_break.str "Specimen Strength"
    from conc_test inner join cyl_break on conc_test.pour_no = cyl_break.pour_no, prod_poured
    where conc_test.pour_no = prod_poured.test_id and prod_poured.job_no = '9-12-821';It gives me the right results but wayyy too many of them so obviously I've got something wrong.
    the results it gives are this:
    Pour Number     Cylinder ID     Pour Date     Mix #     Ambient Temperature     Concrete Temperature     Air %     Break Date     Age (Days)     Specified Strength     Specimen Strength
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6The results I need it to give are this:
    100322A     100322A3     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.6
    100322A     100322A4     22-MAR-10     10     16     16     4.2     19-APR-10     28     35     50.4
    100324A     100324A3     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     51.9
    100324A     100324A4     24-MAR-10     10     9     15     5.8     21-APR-10     28     35     50.8
    100324E     100324E3     24-MAR-10     10     10     15     6     21-APR-10     28     35     50.7
    100324E     100324E4     24-MAR-10     10     10     15     6     21-APR-10     28     35     51.6
    100326B     100326B3     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     48.3
    100326B     100326B4     26-MAR-10     10     9     15     5.7     23-APR-10     28     35     49As you can see my query provides the right results, just way too many of them. I only need to have one result per cylinder id.
    I can't seem to wrap my mind around this one and if somebody could put together a proper select based on what I need that would be extremely helpful. If you need any more data to provide help just ask and I'll paste it.
    Thanks,
    dtr
    Edited by: dtr on Apr 26, 2010 11:12 AM

    dtr wrote:
    Hi,
    Here are the create table statements:
    create table conc_test
    (p_date date, job_no varchar, mix varchar, pour_no varchar, amb_t varchar, conc_t varchar, slump varchar, air varchar, density varchar, cyl_cast_time timestamp)
    create table cyl_break
    (job_no varchar, pour_no varchar, cyl_id varchar, pour_d varchar, break_d varchar, age varchar, spec_str varchar, str varchar, mix);
    create table prod_poured
    (prod_id varchar, pour_id varchar, test_id varchar);
    Great!
    Don't forget to post the INSERT statements, and the output from that data (if it is different from what you posted in your first message).
    Basically I need to pull the data I showed above out of conc_test and cyl_break, but only data that has the proper job_number which is retrieved from the prod_poured table. The prod_poured test_id for everything that has the proper prod_poured job_no So an IN-subquery, like Sudhakar and I suggested, should work.
    What was the problem when you tried them? Post the query you ran, even if you just copied and pasted it from this thread: there may have be an editing error.
    prod_poured test_id is the same thing as conc_test pour_no and cyl_break pour_noExactly! But that doesn't answer the question: Is that value unique in all the tables? If not, in which tables can it be duplicated?

  • How do you Select data from two tables with similar data amd merge the output together.

    I have two Tables containing Sales Data. I want to read the Table a sort by date and accumulate dollars by order date. Then I want to read the second table and accumulate these dollar amounts by date and then merge the records together so that I gave 1 row
    with amounts for type A and amounts for type b.
    Here are the tables I am looking at.
    Select Cast(J.Order_Date As Varchar(11))) As [Order Date]
              ,Sum(Case when Sales_Code like '%Comm%' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Comm]
              ,Sum(Case when Sales_Code = '5-Day' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
              ,Sum(Case when Sales_Code like '%Auto%" then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
              ,Sum(Case when Sales_Code = '' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Fixed]
              ,Sum(Case when Sales_Code = 'XX' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Comm)
              ,Sum(Case when Sales_Code = 'YY' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Auto)
              ,Sum(Case when Sales_Code = 'ZZ' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Fixed)
    from [PRODUCTION].dbo.Job As J
    union all
    Select Cast(SH.Order_Date As Varchar(11))) As [Order Date]
              ,Sum(Case when Sales_Code like '%Comm%' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Comm]
              ,Sum(Case when Sales_Code = '5-Day'     then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
              ,Sum(Case when Sales_Code like '%Auto%" then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
              ,Sum(Case when Sales_Code = ''          then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Fixed]
              ,Sum(Case when Sales_Code = 'XX' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Comm)
              ,Sum(Case when Sales_Code = 'YY' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Auto)
              ,Sum(Case when Sales_Code = 'ZZ' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Fixed)
    from [PRODUCTION].dbo.SO_Detail As SD
    Inner Join [PRODUCTION].dbo.SO_Header As SH
        on SD.Sales_Order = SH.Sales_Order
    Group by J.Order_Date
    Order by J.Order_Date Desc
    Looking for output like
    Order Date   Job Comm   Job AUto   Job Fixed    SO Comm  SO AUto  SO Fixed
    Mar-11-2014    100.00     250.00       50.00     200.00   300.00    400.00
    Mar-10-2014    500.00     340.00        0.00     110.00   400.00    500.00
    Mar-09-2014    600.00     333.00       56.00     210.00   500.00    300.00
    Thanks for your help
    SWProduction

    Seeing the output it looks like what you need is this
    select COALESCE(p.[Order Date],q.[Order Date]) AS [Order Date],
    COALESCE([Job Comm],0) AS [Job Comm],
    COALESCE([Job AUto],0) AS [Job AUto],COALESCE([Job Fixed],0) AS [Job Fixed],COALESCE([SO Comm],0) AS [SO Comm],COALESCE([SO AUto],0) AS [SO AUto],COALESCE([SO Fixed],0) AS [SO Fixed]
    from
    Select Cast(J.Order_Date As Varchar(11))) As [Order Date]
    ,Sum(Case when Sales_Code like '%Comm%' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Comm]
    ,Sum(Case when Sales_Code = '5-Day' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
    ,Sum(Case when Sales_Code like '%Auto%" then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Auto]
    ,Sum(Case when Sales_Code = '' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [Job Fixed]
    ,Sum(Case when Sales_Code = 'XX' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Comm)
    ,Sum(Case when Sales_Code = 'YY' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Auto)
    ,Sum(Case when Sales_Code = 'ZZ' then (J.Order_Quantity * J.Unit_Price) Else 0 end) As Decimal(11,2) As [SO Fixed)
    from [PRODUCTION].dbo.Job As J
    )p
    full join
    Select Cast(SH.Order_Date As Varchar(11))) As [Order Date]
    ,Sum(Case when Sales_Code like '%Comm%' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Comm]
    ,Sum(Case when Sales_Code = '5-Day' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
    ,Sum(Case when Sales_Code like '%Auto%" then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Auto]
    ,Sum(Case when Sales_Code = '' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [SO Fixed]
    ,Sum(Case when Sales_Code = 'XX' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Comm)
    ,Sum(Case when Sales_Code = 'YY' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Auto)
    ,Sum(Case when Sales_Code = 'ZZ' then SD.Ext_Amt Else 0 end) As Decimal(11,2) As [Job Fixed)
    from [PRODUCTION].dbo.SO_Detail As SD
    Inner Join [PRODUCTION].dbo.SO_Header As SH
    on SD.Sales_Order = SH.Sales_Order
    Group by J.Order_Date
    )q
    on p.[Order Date] = q.[Order Date]
    Order by COALESCE(p.[Order Date],q.[Order Date]) Desc
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Data from 3 tables having latest dates

    Hi,
    Need some help with PL/SQL code, I need to write a code which will get data from 3 tables all with the latest date.
    For a particular ACT_CODE the output of the SQL query should show data having the latest dates from 3 tables, if there is no
    date in the table, it should show the remaining data (think left join will do the trick here)
    Table Names:
    Institution_UPDT aiu
    ASQ_CONTACT ac
    GR_AUTHORIZE gr
    All 3 tables have ACT_Code as common                     
    Column Names
    INSTITUTION_UPDT aiu -- aiu.ACT_CODE,aiu.project_id as proj,aiu.UPDT_TYPE_ID, aiu.USER_ID, aiu.UPDT_DATE
    ASQ_CONTACT ac -- ac.ACT_CODE as contact_code,ac.project_id,ac.first_name, ac.middle_initial,ac.last_
    name,ac.title,ac.status,ac.status_date
    GR_AUTHORIZE gr --gr.ACT_CODE as grad_code,gr.name, gr.title AS grad_title, gr.submit_date
    The date column names are
    ac.status_date,
    aiu.UPDT_DATE and
    gr.submit_date
    Thank you everyone
    appreciate your help
    Jesh

    Hi, Jesh,
    user11095252 wrote:
    That is correct, I want to include all the columns from ASQ_Contacts, Institution_UPDT and GR_AUTHORIZEOh! You want all columns from all three tables, not just ASQ_Contacts. That changes the problem considerably!
    UNION requires that all prongs have the same number of columns, and that the datatypes of the columns match. That's no problem if we just need act_code and a date from each one. If we just need additional columns from one table, it's easy to add literal NULLs to the other prongs to serve as the additional columns. But if we need all (or even several) columns from all three tables, that's no good. So let's revert to your original idea: outer joins.
    I want to display only one row which has the latest date with the most recently updated time (example:mm/dd/yyyy hr:min:sec am/pm)Yes, but what if there is a tie for the most recently updated time?
    In case of a tie, the query below will pick one of the contenders arbitrarily. That may be fine with you (e.g., you may have UNIQUE constraints, making ties impossible). If you need a tie-breaker, yiou can add more columns to the analytic ORDER BY clauses.
    WITH     aiu     AS
         SELECT     institution_updt.*     -- or list columns wanted
         ,     ROW_NUMBER () OVER ( PARTITION BY  act_code
                             ORDER BY        updt_date     DESC
                           ) AS r_num
    FROM     institution_updt
    WHERE     act_code     = :p1_act_code
    AND     project_id     = :p2_project_id
    ,     ac     AS
         SELECT     asq_contact.*          -- or list columns wanted
         ,     ROW_NUMBER () OVER ( PARTITION BY  act_code
                             ORDER BY        status_date     DESC
                           ) AS r_num
    FROM     asq_contact
    WHERE     act_code     = :p1_act_code
    AND     project_id     = :p2_project_id
    ,     gr     AS
         SELECT     gr_authorize.*          -- or list columns wanted
         ,     ROW_NUMBER () OVER ( PARTITION BY  act_code
                             ORDER BY        submit_date     DESC
                           ) AS r_num
    FROM     gr_authorize
    WHERE     act_code     = :p1_act_code
    SELECT     *     -- or list columns wanted
    FROM          aiu
    FULL OUTER JOIN     ac     ON     ac.act_code     = aiu.act_code
                   AND     ac.r_num     = 1
                   AND     aiu.r_num     = 1
    FULL OUTER JOIN     gr     ON     gr.act_code     = NVL (ac.act_code, aiu_act_code)
                   AND     gr.r_num     = 1
    ;That's a lot of code, so there may be typos. If you'd post CREATE TABLE and INSERT statements for a few rows of sample data, I could test it.
    In all places where I said "SELECT *" above, you may want to list the individual columns you want.
    If you do that in the sub-queries, then you don't have to qualify the names with the table name: that's only required when saying "SELECT *" with another column (r_num, in this case).
    It's more likely that you won't want to say "SELECT *" in the main query. The three r_num columns, while essential to the query, are completely useless to your readers, and you might prefer to have just one act_code column, since it will be the same for all tables that have it. But since it may be NULL in any of the tables, you'll have to SELECT it like this:
    SELECT  COALESCE ( aiu.act_code
                     , ac.act_code
                     , gr_act_code
                     )  AS act_codeThe query above will actually work for multiple act_codes. You can change the condidition to something like
    WHERE   act_code IN (&act_code_list)If so, remember to change it in all three sub-queries.

  • To select from database table based on date range

    hi
    i have a selection screen in which date range is being given
    say eg 23/06/07  to 23/12/08
    based on this date i want to select data from a ztable
    eg i want to select a field amount from table
    and three is a field date range on the table
    for this particular field i want to select all records for amount field  and factual field falling wiithing this date range and sum it
    eg
    based on date range as in selcetion screen
    select amount( field1)  factual ( field2) from ztable into it_ztable where date = ?....
    please give me code for it  and how to sum all values as i will get from the ztable into internal table the two values as fetched from the ztable
    please suggest asap
    regards
    arora

    hi
    i am using
    sELECT field1 field2 FROM Ztable  INto it_matu
                       where DATE GE sl_dat-low    
                        AND  DATE LE sl_dat-high.   
    i am getting data in internal table but
    say i have twelve records now i want to sum it the both the columns into and use that sum final amount to display
    let me know how to use sume in the intrranal tabl do i need to use control statement
    how to use the sum for two columns and take into a serperate variable to display
    regards
    aRora

  • Select from 4 tables but include data from 3 even if 4th is null

    Hello -
    I'm quite new to oracle and apex, but enjoying learning - but sometimes I need a gentle nudge to know what I need to learn about.
    I have a select statement that works - selecting specific columns from 3 tables:
    SELECT
    "TERRITORIES"."TER_NAME" "TER_NAME",
    "TERRITORY_TYPES"."TTP_DESCRIPTION" "TTP_DESCRIPTION",
    "COUNTRIES"."CNT_DESCRIPTION" "COUNTRY"
    FROM
    "TERRITORIES", "TERRITORY_TYPES","COUNTRIES"
    WHERE
    "TERRITORIES"."TER_TTP_ID"="TERRITORY_TYPES"."TTP_ID"
    and
    "COUNTRIES"."CNT_TER_ID"="TERRITORIES"."TER_ID"
    I want to add in a 4th table for, you guessed it, States.
    However, many of the countries do not yet have states in the states table (and may never have any). Therefore, they do not appear in the results. I want them included in the query, so that I'll have the opportunity to add in the data via Apex.
    Is there a phrase I can insert in the 1st query so that I'll get data for Territory Type, Territory and Country, even if the State table is null?
    Or, do I need to insert records into the state table, such as: insert into states (state_ID, STATE_CNT_ID) values (state_seq.nextval,2). If so, do I just do that over and over, replacing the value? Or is this where I need to learn about bind variables? Or some other command?
    Thank you-
    Marion in NY
    Edited by: mtpaper on Oct 24, 2009 12:54 PM
    I FIGURED IT OUT! I DID IT! How do I mark myself as helpful???
    insert INTO states
    (state_ID, STATE_CNT_ID)
    SELECT state_seq.nextval, cnt_id
    FROM countries
    WHERE not exists (select * from states where states.state_cnt_id = countries.cnt_id)
    Edited by: mtpaper on Oct 24, 2009 1:10 PM

    You certainly could insert data into the STATES table, but I generally wouldn't advise inserting rows into a STATES table for states that don't actually exist. It would seem to make far more sense to just do an outer join when you include the STATES table in your query
    SELECT "TERRITORIES"."TER_NAME" "TER_NAME",
           "TERRITORY_TYPES"."TTP_DESCRIPTION" "TTP_DESCRIPTION",
           "COUNTRIES"."CNT_DESCRIPTION" "COUNTRY",
           s.state_name
      FROM TERRITORIES t ,
           TERRITORY_TYPES tt,
           COUNTRIES c,
           states s
    WHERE "TERRITORIES"."TER_TTP_ID"="TERRITORY_TYPES"."TTP_ID"
       and "COUNTRIES"."CNT_TER_ID"="TERRITORIES"."TER_ID"
       and c.cnt_id = s.state_cnt_id(+)The {noformat}(+){noformat} operator indicates that you want to do an outer join. So if there is no row in the STATES table that matches the join condition, a NULL is returned.
    From a purely stylistic standpoint, I would generally suggest using aliases (i.e. the T, TT, C, and S in the FROM clause) rather than having to constantly write out all the table names. And I wouldn't suggest putting double-quotes around everything-- that forces all your identifiers to be upper case and case sensitive.
    Justin

  • SAP GRC 10.1 AMF No data selected when adding duplicate fields from separate tables for configurable data sources

    Hi There,
    In SAP GRC 10.0, our team had an issue where we could not add duplicate fields from separate table (see ERROR: Select Currency/UoM field for the selected analyzed fields). This was resolved by the SAP Note 1904313/ 1904314 (http://service.sap.com/sap/support/notes/1904313).
    We upgraded our system to SAP GRC 10.1 SP05 and could now add the duplicate fields from separate tables. SAP Note 1904313/ 1904314 was part of SAP GRC 10.1 SP03 so it makes sense that we, in a higher version (SP05), would be able to do this.
    The issue now is when we add the duplicate fields from different tables and run the Ad-hoc Query to test if the data source works correctly, the No Data Selected warning persists. This means that the data source provides no data for analysis, which is required to write our business rules.
    Below is an example:
    Basic data source with just one currency reference field EBAN-WAERS.
    When you run the Ad-Hoc Query you receive data.
    Basic data source with second currency reference field EKKO-WAERS.
    When you run the Ad-Hoc Query no data is found.
    Please also make reference to the following thread logged by my colleague (ERROR: Select Currency/UoM field for the selected analyzed fields)
    Any assistance to receive data with duplicate fields from separate tables will be highly appreciated.
    Thanking you in advance.
    Regards
    Gary Khan

    Hi
    following are the  error messages from dump
    hrtText
       There is already a line with the same key.
    hat happened?
       Error in ABAP application program.
       The current ABAP program "SAPLCKMS" had to be terminated because one of the
       statements could not be executed.
       This is probably due to an error in the ABAP program.
    rror analysis
       You wanted to add an entry to table "\FUNCTION-POOL=CKMS\DATA=T_DYN_CKMLCR",
        which you declared
       with a UNIQUE KEY. However, there was already an entry with the
       same key.
       This may have been in an INSERT or MOVE statement, or within a
       SELECT ... INTO statement.
       In particular, you cannot insert more than one initial line into a
       table with a unique key using the INSERT INITIAL LINE... statement.
    rigger Location of Runtime Error
       Program                                 SAPLCKMS
       Include                                 LCKMSF01
       Row                                     226
       Module type                             (FORM)
       Module Name                             DYNAMIC_PERIOD_CLOSING
    Source code where dump ocured
    222
    223           APPEND ht_ckmlpp TO t_add_ckmlpp.
    224           APPEND LINES OF ht_ckmlcr TO t_add_ckmlcr.
    225           INSERT ht_ckmlpp INTO TABLE t_dyn_ckmlpp.
    >>>>           INSERT LINES OF ht_ckmlcr INTO TABLE t_dyn_ckmlcr.
    227         ENDWHILE.
    Also I guess there is problem with material ledger in R/3 side
    I have never worked on material ledger before so dont hav idea of Tcode and tables in SAP R/3 for material ledger.
    Thanks
    Navneet

  • Exception While Opening a Pop Up From Pivot Table

    Hi,
    I actually created a pivot table which has the cell data filled with images. I would like to have these images to function as 'CommangImageLink' and onclick of the image ... should open a popup to display the details about that intersection.
    For ex : I have Products Vs State as Row & Column Header. For each intersection of Product Vs State .... depends upon the availability of the inventory should render an image. And on click of the image .. should display the details of the inventory for that intersection in a pop up.
    Does any one of you have any idea about this.
    FYI ... here is the piece of code which im using. When use this code ... getting the below mentioned exception.
    <dvt:pivotTable id="pt1" var="cellData" varStatus="cellStatus"
                          inlineStyle="width:800px;height:350px"
                          value="#{bindings.MecOverviewJobsVO.pivotTableModel}"
                          binding="#{backingBeanScope.backing_jsff_mecStatusview.pt1}"
                          sizing="auto" pivotLabelVisible="false">
            <dvt:dataCell>
              <!--af:activeImage source="#{cellData.dataValue == 0 ? '/images/green.jpg;':(cellData.dataValue == 1? '/images/yellow.jpg;':(cellData.dataValue == 2?'/images/red.jpg;':(cellData.dataValue == 3?'/images/blue.jpg;':'/images/white.JPG;')))}"
                              binding="#{backingBeanScope.backing_jsff_mecStatusview.ai1}"
                              id="ai1"/-->
                              <af:commandImageLink id="cil1" icon="#{cellData.dataValue == 0 ? '/images/green.jpg;':(cellData.dataValue == 1? '/images/yellow.jpg;':(cellData.dataValue == 2?'/images/red.jpg;':(cellData.dataValue == 3?'/images/blue.jpg;':'/images/white.JPG;')))}"
                                                   actionListener="#{backingBeanScope.backing_jsff_mecStatusview.imageClicked}"/>
              <af:popup id="showDetailsPopUp"
                        binding="#{backingBeanScope.backing_jsff_mecStatusview.showDetailsPopUp}">
                    <af:dialog id="d1" title="Hi..."/>
              </af:popup>
            </dvt:dataCell>
          </dvt:pivotTable>EXCEPTION ..........
    DCUtil> <findSpelObject> [7517] DCUtil, returning:oracle.adfinternal.view.faces.dvt.model.binding.pivotTable.FacesPivotTableBinding, for MecOverviewJobsVO
    <UIXRegion> <_warn> Error processing viewId: /mecui-flow/mecStatusview URI: /jsff/mecStatusview.jsff actual-URI: /jsff/mecStatusview.jsff.
    oracle.dss.util.transform.TransformRuntimeException: DVT-2015 Slice -1 exceeds boundary 9.
    oracle.dss.util.SliceOutOfRangeException: DVT-2015 Slice -1 exceeds boundary 9.
         at oracle.dss.util.transform.CubicDataAccess.getValue(CubicDataAccess.java:908)
         at oracle.dss.util.transform.CubicDataAccess.getValue(CubicDataAccess.java:1448)
         at oracle.adf.view.faces.bi.component.pivotTable.UIPivotTable.getCurrentCellContext(UIPivotTable.java:1202)
         at oracle.adf.view.faces.bi.component.pivotTable.UIPivotTable.getStamps(UIPivotTable.java:1113)
         at oracle.adf.view.faces.bi.component.pivotTable.UIGrid._restoreStampState(UIGrid.java:1362)
         at oracle.adf.view.faces.bi.component.pivotTable.UIGrid.postCellDataChange(UIGrid.java:830)
         at oracle.adf.view.faces.bi.component.pivotTable.UIPivotTable.postCellDataChange(UIPivotTable.java:1315)
         at oracle.adf.view.faces.bi.component.pivotTable.UIGrid.setCellKey(UIGrid.java:506)
    <DCIteratorBinding> <releaseDataInternal> [7527] Releasing iterator binding:MecOverviewJobsVOIterator
    <RegistrationConfigurator> <handleError> ADF_FACES-60096:Server Exception during PPR, #1
    oracle.dss.util.transform.TransformRuntimeException: DVT-2015 Slice -1 exceeds boundary 9.
    oracle.dss.util.SliceOutOfRangeException: DVT-2015 Slice -1 exceeds boundary 9.
         at oracle.dss.util.transform.CubicDataAccess.getValue(CubicDataAccess.java:908)
         at oracle.dss.util.transform.CubicDataAccess.getValue(CubicDataAccess.java:1448)
         at oracle.adf.view.faces.bi.component.pivotTable.UIPivotTable.getCurrentCellContext(UIPivotTable.java:1202)
         at oracle.adf.view.faces.bi.component.pivotTable.UIPivotTable.getStamps(UIPivotTable.java:1113)
         at oracle.adf.view.faces.bi.component.pivotTable.UIGrid._restoreStampState(UIGrid.java:1362)
         at oracle.adf.view.faces.bi.component.pivotTable.UIGrid.postCellDataChange(UIGrid.java:830)
         at oracle.adf.view.faces.bi.component.pivotTable.UIPivotTable.postCellDataChange(UIPivotTable.java:1315)
         Thanks & Regards,
    Kiran Konjeti

    Hi Frank,
    Thank you very much for your reply.
    Yes. The active image code was commented and we are not using it.
    And i tried with placing the pop up outside of pivot table but still getting the same issue.
    JDev Version : Build JDEVADF_11.1.1.5.0_GENERIC_110409.0025.6013
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:dvt="http://xmlns.oracle.com/dss/adf/faces">
      <af:panelStretchLayout binding="#{backingBeanScope.backing_jsff_mecStatusview.psl1}"
                             id="psl1" bottomHeight="87px" startWidth="30px"
                             endWidth="30px">
        <f:facet name="center">
          <dvt:pivotTable id="pt1" var="cellData" varStatus="cellStatus"
                          inlineStyle="width:800px;height:350px"
                          value="#{bindings.MecOverviewJobsVO.pivotTableModel}"
                          binding="#{backingBeanScope.backing_jsff_mecStatusview.pt1}"
                          sizing="auto" pivotLabelVisible="false">
            <dvt:dataCell>
              <af:commandImageLink id="cil2" icon="/images/green.jpg" iconPosition="leading" rendered="#{cellData.dataValue == 0}" actionListener="#{backingBeanScope.backing_jsff_mecStatusview.imageClicked}"/>        
            </dvt:dataCell>
          </dvt:pivotTable>
        </f:facet>
        <f:facet name="bottom">
          <af:panelGroupLayout binding="#{backingBeanScope.backing_jsff_mecStatusview.pgl1}"
                               id="pgl1">
             <af:popup id="showDetailsPopUp"
                        binding="#{backingBeanScope.backing_jsff_mecStatusview.showDetailsPopUp}">
                    <af:dialog id="d1" title="Hi..."/>
              </af:popup>
         </af:panelGroupLayout >
       </f:facet >
      </af:panelStretchLayout>
    </jsp:root>Please let me know your comments.
    Thanks & Regards,
    Kiran Konjeti

Maybe you are looking for

  • Free goods PO query

    Hi Gurus, Sometimes we imported the goods as free. Although we did not pay anything to the vendor, we should pay custom and transportation expense to the related vendor.During PO creation in SAP, we are entering custom and transport expense as condit

  • My Itunes Keeps Crashing every 10 minutes.

    For the past few weeks, I have been starting my imac up, go to itunes, it sits for a few mintues then crashes... I get the following comment in the dialogue box.... Process:         iTunes [10009] Path:            /Applications/iTunes.app/Contents/Ma

  • What are the in puts for this FM?

    Hi All...     Iam uploading flat file data from Ecell file what are the inputs for file type and Has -field sepearator in GUI_UPLOAD fm? Thanks, Naveen.i

  • Password Protecting An entire folder in documents?

    I need to be able to password protect a folder within my Documents folder, as it contains very sensitive info. Does anyone know how to do this in pages '09? Thanks

  • ORABPEL-04076 - How to resolve?

    The big picture is that I am looking to check out the Oracle BPEL Process Manager on my JBoss system. I have used other BPEL products (even Collaxa a few years back), but my experience with Oracle is limited. Following Section 3 in the "Oracle BPEL P