Pivot without an aggregate

Hi we run 2012 enterprise and I see a lot of articles about pivoting without an aggregate but honestly they all seem to use some sort of aggregate function, usually min because they can get away with it.
My data comes in as pk,colA_error,colB_error,colC_error...
Each error is an integer error code an there can be multiples and/or duplicates for the same column in the same pk.  An error code can be null.
I'd like to pivot the data as follows...
pk, name of error column, error code.  I have no problem getting rid of dupes independently of the pivot query.  My column names are static.
Do I have a prayer?

thx Scott, my bad.  Unpivot was what i wanted and its working fine.  
select pk_file,[ErrorC],[Column]
from (select pk_file,
[colA_Error],
[colB_Error]
from [dbo].[v_fileEdit]) p
unpivot
[ErrorC] for [Column] in ([colA_Error],
[colB_Error])
) as unpvt;

Similar Messages

  • Issue in pivot while using aggregate functions

    when I use this below query in oracle sql developer
    ------------->select sum(round(8.08/0.54,2)*30) from dual.
    i am getting result as 448.8.it is a correct value
    but i use this below queries in pivot as same like above query i am getting result of doubled value 914.4.
    PIVOT
    SUM(round(ROUND(sellout,2)/6,2)) AS LAST_6_MON_SELL_OUT,
    SUM(ROUND(inventory,2)) AS INVENTORY_INTINS_1,
    Sum(round(ROUND(inventory,2)/round(ROUND(sellout,2)/6,2),2)*30) As Stockperday
    FOR PRODUCT IN (56,78)
    actually i am getting value for SUM(round(ROUND(sellout,2)/6,2)) is 0.54,*SUM(ROUND(inventory,2))* is 8.08 i the above query ,but i am getting wrong value for this aggregate function Sum(round(ROUND(inventory,2)/round(ROUND(sellout,2)/6,2),2)30)* as 914.4.but actual value is 448.8
    why this problem.can anybody explain me.why this problem

    Try ur luck in 'sql plsql thread'
    PL/SQL

  • How I can change a power pivot without change the power charts that are suing that power pivot as source?

    Hi All
    My issues using an Example, 
    I've a power pivot with 3 related tables, (two dimension tables and one measure table), then I created a pivot chart using
    that 3 tables as source... 
    The pivot chart is a little complex... it takes some time to rebuild from the scratch... I have added 3 measures to the chart,
    M1, M2, M3... but due to a business changes I need to refresh the measures M1, M2, M3 with information from a different source...
    i.e. I need to drop the 3 measures from the Power Pivot, then I need to add them again with the same names, but when I drop
    them from the power pivot table  the pivot Chart Fields Values disappear and the chart obviously is refreshed without the 3 measures... :S
    Question: How can I drop a column from a power pivot table, then add it again with the same name without affect the Pivot
    Chart Fields... i.e. only when I do the refresh manually the charts are affected... but once the name of the columns are the same.. the charts don't change the layout....
    Thanks Very Much!!!
    Luis

    Luis,
    Any luck with this?
    Thanks!
    Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Pivot table wihtout Aggregate Functions ( Urgent Please. )

    I am trying to select date and time. But having a hard time since I dont have any aggregate function that is needed. Just pivot the rows to columns.
    IN sql 
    stage
    starttime
    endtime
    1
    1/22/2011 15:31
    1/22/2011 15:32
    2
    1/22/2011 15:33
    1/22/2011 15:34
    3
    1/22/2011 15:35
    1/22/2011 15:36
    Required 
    starttime_s1
    endtime_s1
    starttime__s2
    endtime_s2
    starttime_s3
    endtime_s3
    1/22/2011 15:31
    1/22/2011 15:32
    1/22/2011 15:33
    1/22/2011 15:34
    1/22/2011 15:35
    1/22/2011 15:36

    What is it that you're trying to accomplish with this?
    The reason I ask is that pivoting data is a display function and therefore best left to the application or reporting tier.
    If you're going to insist on "driving screws with a hammer" and really want to do this in SQL, the next question is, Is there a set number of "Stages" that will exist? Is it always going to be 3 stages and only 3 stages?
    If the answer is YES, there will be a fixed number of stages, then it's a simple thing to do with either a PIVOT or CASE statements. (my personal preference is to use case statements, especially if you're pivoting 2 or more columns)
    If the answer is NO, the number is stages can vary... You're left with a Dynamic PIVOT. Dynamic Pivots are a bit more complex to write but there is enough sample code out on the interwebs that you won't have a problem finding the correct syntax. 
    The real problem with a Dynamic Pivot query is the fact that it's pretty much useless. You can't do much (if anything at all) with it... Due to the fact that they have variable numbers of columns, they can't be used in views or procs and I can't think of
    a singe, off the shelf, reporting platform that will allow accommodate data source that has a different number of columns every time it executes... So unless you're going to be content looking at the results in SSMS or developing a custom application, I don't
    see the point.
    Also... Aggregates aren't a problem based on the data you're showing. You only have 1 start time and 1 end time per stage. Using either the MIN or MAX aggregate functions will work to give you the desired result.
    Anyway, hope that helps,
    Jason
    Jason Long

  • Pivot without Corner Labels in Report

    Hello,
    I have a simple Pivot (2 Row Labels, 1 Fact). In the Pivot Section all Corner Lables (tick on Row) are visible. When I place the same Pivot into the Report Section I only see the label for the first Row and the Fact. The second is missing. Going back to the Pivot section all labels visible.
    I tried to add more rows to the pivot. In the Report Section always the first Row Label and all Fact Labels are visible only. The rest is missing.
    Any idea why?
    Hyperion Interactive Reporting Studio 9.3.1
    Thanks.

    Hi,
    After you placed the pivot on the Report section, did you try resizing it to let you see all the row-labels ?
    Unfortunately, the Pivot section doesn't auto-expand, once we drag it on to Report section. We've to manually re-size it to display all the required fields/columns.

  • Pivot type query without aggregate function. Transposing

    Hi experts,
    Oracle 11g.
    I have a table (see code example to reproduce), that has a date, a grouping, and the count of that grouping (determined in another query). I need a pivot type query, but, without the aggregate functions. This is just for a report display. I can not seem to figure this one out. Thanks for your help.
    CREATE TABLE temp_task
    AS
       SELECT TO_DATE ('15-NOV-2012') validation_date,
              'GROUP 1' AS group_number,
              42 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('14-DEC-2012') validation_date,
              'GROUP 1' AS group_number,
              33 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('15-NOV-2012') validation_date,
              'GROUP 2' AS group_number,
              10 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('14-DEC-2012') validation_date,
              'GROUP 2' AS group_number,
              32 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('15-NOV-2012') validation_date,
              'GROUP 3' AS group_number,
              7 AS monthly_count
         FROM DUAL
       UNION ALL
       SELECT TO_DATE ('14-DEC-2012') validation_date,
              'GROUP 3' AS group_number,
              9 AS monthly_count
         FROM DUAL;Using only SQL I need to return the following:
    VALIDATION_DATE | GROUP 1 | GROUP 2 | GROUP 3
    11/15/2012 | 42 | 10 | 7
    12/14/2012 | 33 | 32 | 9

    Hi
    You always need to use an aggregate function while pivoting.
    Even if you don't really need any aggregation, that is, when what you see in the table is what you'll get in the result set, you still have to use an aggregate function. If there will only be one value contrinuting to each cell, then you can use MIN or MAX. It won't matter which; since there's only 1 value, that value will be the highest of the 1, and it will also be the lowest. For NUMBER columns, you could also use SUM or AVG.
    SELECT       *
    FROM       temp_task
    PIVOT       ( MIN (monthly_count)
             FOR group_number IN ( 'GROUP 1'
                                 , 'GROUP 2'
                        , 'GROUP 3'
    ORDER BY  validation_date
    ; Output:
    VALIDATION_  'GROUP 1'  'GROUP 2'  'GROUP 3'
    15-Nov-2012         42         10          7
    14-Dec-2012         33         32          9It sounds like you're doing real aggregation someplace, to get monthly_count. Maybe it would be simpler and more efficient to do the pivoting at that point. What is the big picture here? Post some sample data as it is before you compute monthly_count, and the results you want from that data (if different from what you've already posted), and then let's see if we can't aggregte it and pivot it at the same time.

  • Displaying dimension  after measures in Pivot view

    Hi
    I have a requirement to display some of the dimension columns after the measure columns in pivot view. How do I achieve this?
    Any suggestions would be considered helpful.
    Thanks in Advance
    Regards
    Amrith

    If this is a text field, you have to create a formula as :
    Max(Table.Column by the others columns in the pivot without the excluded columns)Then you drag and drop this column in the measures
    If you have excluded columns, you must set a max aggregate on this column in the pivot.
    And this answer don't need to be considered as helpful. It's free. ;-)
    Cheers
    Nico

  • Aggregate function in the query

    Hi gurus,
    What makes presentation layer send queries with Aggregate( by ) function eventhough this function is not used in the column formulas?
    Now comes a long explanation - only for the patient ones :-)
    I am working OBIEE / Essbase.
    A strange thing happened to one of my reports - exactly the same report (pivot) in production (old repository) works fine, but brings wrong results on the new repository.
    I found out that SQL sent to OBIEE is different.
    With old repository, it sends a query with 'Aggregate ( by)' function used for measures. However with the new one, it sends just column names without the Aggregate.
    Where shall I look for the difference?
    -- OLD (Good) query -----------
    SELECT DIM_BATCH_HEADERS."Gen3,DIM_BATCH_HEADERS" saw_0,
    PROD_QTY.PROD_ACTUAL_QTY_KG/1000 saw_1,
    DIM_COMPONENT."Gen3,DIM_COMPONENT" saw_2, ' ' saw_3,
    COST.COMP_ACTUAL_COST_ILS_PER_TON saw_4, 0 saw_5,
    COST.ACTUAL_COST_K_ILS saw_6, 0 saw_7,
    AGGREGATE(saw_1 BY ),
    AGGREGATE(saw_4 BY ),
    AGGREGATE(saw_6 BY ),
    AGGREGATE(saw_1 BY saw_0, saw_5),
    AGGREGATE(saw_4 BY saw_0, saw_5),
    AGGREGATE(saw_6 BY saw_0, saw_5)
    FROM "COP_MAAD#1" WHERE (COMP_QTY.COMP_RELEVANT > 0)
    AND (DIM_TIME."YEAR" = '2009')
    AND (DIM_BATCH_HEADERS."Gen2,DIM_BATCH_HEADERS" = 'ABC')
    ORDER BY saw_1 DESC, saw_4 DESC, saw_0, saw_2, saw_3, saw_5, saw_7
    -- NEW (Incorrect) Query ---------------
    SELECT DIM_BATCH_HEADERS."Gen3,DIM_BATCH_HEADERS" saw_0,
    PROD_QTY.PROD_ACTUAL_QTY_KG/1000 saw_1,
    DIM_COMPONENT."Gen3,DIM_COMPONENT" saw_2,
    ' ' saw_3, COST.COMP_ACTUAL_COST_ILS_PER_TON saw_4,
    0 saw_5,
    COST.ACTUAL_COST_K_ILS saw_6,
    0 saw_7 FROM "COP_MAAD#1"
    WHERE (COMP_QTY.COMP_RELEVANT > 0) AND (DIM_TIME."YEAR" = '2009')
    AND (DIM_BATCH_HEADERS."Gen2,DIM_BATCH_HEADERS" = 'ABC') ORDER BY saw_1 DESC, saw_4 DESC
    Thanks,
    Alex

    Hi,
    Can anybody reply to the above question please?
    regards,
    Siva

  • Power Query Doesn't Load Complete CSV FIle After Pivot Transform

    Hello, After transforming a CSV file using the following code I can load the entire file (45,000 rows) into the Excel Data Model.
    let
    Source = Csv.Document(File.Contents("C:\Users\jd\Desktop\2014 JW Annual Review\ALL STORES 01-07-15 AR OPEN.csv"),null,",",null,1252),
    #"First Row as Header" = Table.PromoteHeaders(Source),
    #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"AR-OPEN", type text}, {"SALE CO", type text}, {"NAME", type text}, {"N-CD", Int64.Type}, {"REFER", type text}, {"JRNL CO", type text}, {"SCHED", type text}, {"AGME.CO.ID", Int64.Type}, {"SO", type text}, {"ODATE", type text}, {"JRNL TYPE", type text}, {"CONTROL", type text}, {"DATE", type text}, {"A-ACCT", type text}, {"CONTROL2", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"AR-OPEN"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns","SALE CO",Splitter.SplitTextByDelimiter(" "),{"SALE CO.1", "SALE CO.2", "SALE CO.3", "SALE CO.4", "SALE CO.5", "SALE CO.6", "SALE CO.7", "SALE CO.8", "SALE CO.9", "SALE CO.10", "SALE CO.11", "SALE CO.12", "SALE CO.13", "SALE CO.14", "SALE CO.15", "SALE CO.16", "SALE CO.17", "SALE CO.18", "SALE CO.19", "SALE CO.20", "SALE CO.21", "SALE CO.22", "SALE CO.23", "SALE CO.24", "SALE CO.25"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"SALE CO.1", Int64.Type}, {"SALE CO.2", type text}, {"SALE CO.3", type text}, {"SALE CO.4", type text}, {"SALE CO.5", type text}, {"SALE CO.6", type text}, {"SALE CO.7", type text}, {"SALE CO.8", type text}, {"SALE CO.9", type text}, {"SALE CO.10", type text}, {"SALE CO.11", type text}, {"SALE CO.12", type text}, {"SALE CO.13", type text}, {"SALE CO.14", type text}, {"SALE CO.15", type text}, {"SALE CO.16", type text}, {"SALE CO.17", type text}, {"SALE CO.18", type text}, {"SALE CO.19", type text}, {"SALE CO.20", type text}, {"SALE CO.21", type text}, {"SALE CO.22", type text}, {"SALE CO.23", type text}, {"SALE CO.24", type text}, {"SALE CO.25", type text}, {"NAME_1", type text}, {"DATE_2", type text}, {"NAME_3", type text}, {"CONTROL_4", type text}}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Changed Type1","REFER",Splitter.SplitTextByDelimiter(" "),{"REFER.1", "REFER.2", "REFER.3", "REFER.4", "REFER.5", "REFER.6", "REFER.7", "REFER.8", "REFER.9", "REFER.10", "REFER.11", "REFER.12", "REFER.13", "REFER.14", "REFER.15", "REFER.16", "REFER.17", "REFER.18", "REFER.19", "REFER.20", "REFER.21", "REFER.22", "REFER.23", "REFER.24", "REFER.25"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"REFER.1", type text}, {"REFER.2", type text}, {"REFER.3", type text}, {"REFER.4", type text}, {"REFER.5", type text}, {"REFER.6", type text}, {"REFER.7", type text}, {"REFER.8", type text}, {"REFER.9", type text}, {"REFER.10", type text}, {"REFER.11", type text}, {"REFER.12", type text}, {"REFER.13", type text}, {"REFER.14", type text}, {"REFER.15", type text}, {"REFER.16", type text}, {"REFER.17", type text}, {"REFER.18", type text}, {"REFER.19", type text}, {"REFER.20", type text}, {"REFER.21", type text}, {"REFER.22", type text}, {"REFER.23", type text}, {"REFER.24", type text}, {"REFER.25", type text}}),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Changed Type2","JRNL CO",Splitter.SplitTextByDelimiter(" "),{"JRNL CO.1", "JRNL CO.2", "JRNL CO.3", "JRNL CO.4", "JRNL CO.5", "JRNL CO.6", "JRNL CO.7", "JRNL CO.8", "JRNL CO.9", "JRNL CO.10", "JRNL CO.11", "JRNL CO.12", "JRNL CO.13", "JRNL CO.14", "JRNL CO.15", "JRNL CO.16", "JRNL CO.17", "JRNL CO.18", "JRNL CO.19", "JRNL CO.20", "JRNL CO.21", "JRNL CO.22", "JRNL CO.23", "JRNL CO.24", "JRNL CO.25"}),
    #"Changed Type3" = Table.TransformColumnTypes(#"Split Column by Delimiter2",{{"JRNL CO.1", Int64.Type}, {"JRNL CO.2", type text}, {"JRNL CO.3", type text}, {"JRNL CO.4", type text}, {"JRNL CO.5", type text}, {"JRNL CO.6", type text}, {"JRNL CO.7", type text}, {"JRNL CO.8", type text}, {"JRNL CO.9", type text}, {"JRNL CO.10", type text}, {"JRNL CO.11", type text}, {"JRNL CO.12", type text}, {"JRNL CO.13", type text}, {"JRNL CO.14", type text}, {"JRNL CO.15", type text}, {"JRNL CO.16", type text}, {"JRNL CO.17", type text}, {"JRNL CO.18", type text}, {"JRNL CO.19", type text}, {"JRNL CO.20", type text}, {"JRNL CO.21", type text}, {"JRNL CO.22", type text}, {"JRNL CO.23", type text}, {"JRNL CO.24", type text}, {"JRNL CO.25", type text}}),
    #"Split Column by Delimiter3" = Table.SplitColumn(#"Changed Type3","SO",Splitter.SplitTextByDelimiter(" "),{"SO.1", "SO.2", "SO.3", "SO.4", "SO.5", "SO.6", "SO.7", "SO.8", "SO.9", "SO.10", "SO.11", "SO.12", "SO.13", "SO.14", "SO.15", "SO.16", "SO.17", "SO.18", "SO.19", "SO.20", "SO.21", "SO.22", "SO.23", "SO.24", "SO.25"}),
    #"Changed Type4" = Table.TransformColumnTypes(#"Split Column by Delimiter3",{{"SO.1", Int64.Type}, {"SO.2", type text}, {"SO.3", type text}, {"SO.4", type text}, {"SO.5", type text}, {"SO.6", type text}, {"SO.7", type text}, {"SO.8", type text}, {"SO.9", type text}, {"SO.10", type text}, {"SO.11", type text}, {"SO.12", type text}, {"SO.13", type text}, {"SO.14", type text}, {"SO.15", type text}, {"SO.16", type text}, {"SO.17", type text}, {"SO.18", type text}, {"SO.19", type text}, {"SO.20", type text}, {"SO.21", type text}, {"SO.22", type text}, {"SO.23", type text}, {"SO.24", type text}, {"SO.25", type text}}),
    #"Split Column by Delimiter4" = Table.SplitColumn(#"Changed Type4","ODATE",Splitter.SplitTextByDelimiter(" "),{"ODATE.1", "ODATE.2", "ODATE.3", "ODATE.4", "ODATE.5", "ODATE.6", "ODATE.7", "ODATE.8", "ODATE.9", "ODATE.10", "ODATE.11", "ODATE.12", "ODATE.13", "ODATE.14", "ODATE.15", "ODATE.16", "ODATE.17", "ODATE.18", "ODATE.19", "ODATE.20", "ODATE.21", "ODATE.22", "ODATE.23", "ODATE.24", "ODATE.25"}),
    #"Changed Type5" = Table.TransformColumnTypes(#"Split Column by Delimiter4",{{"ODATE.1", type date}, {"ODATE.2", type text}, {"ODATE.3", type text}, {"ODATE.4", type text}, {"ODATE.5", type text}, {"ODATE.6", type text}, {"ODATE.7", type text}, {"ODATE.8", type text}, {"ODATE.9", type text}, {"ODATE.10", type text}, {"ODATE.11", type text}, {"ODATE.12", type text}, {"ODATE.13", type text}, {"ODATE.14", type text}, {"ODATE.15", type text}, {"ODATE.16", type text}, {"ODATE.17", type text}, {"ODATE.18", type text}, {"ODATE.19", type text}, {"ODATE.20", type text}, {"ODATE.21", type text}, {"ODATE.22", type text}, {"ODATE.23", type text}, {"ODATE.24", type text}, {"ODATE.25", type text}}),
    #"Split Column by Delimiter5" = Table.SplitColumn(#"Changed Type5","JRNL TYPE",Splitter.SplitTextByDelimiter(" "),{"JRNL TYPE.1", "JRNL TYPE.2", "JRNL TYPE.3", "JRNL TYPE.4", "JRNL TYPE.5", "JRNL TYPE.6", "JRNL TYPE.7", "JRNL TYPE.8", "JRNL TYPE.9", "JRNL TYPE.10", "JRNL TYPE.11", "JRNL TYPE.12", "JRNL TYPE.13", "JRNL TYPE.14", "JRNL TYPE.15", "JRNL TYPE.16", "JRNL TYPE.17", "JRNL TYPE.18", "JRNL TYPE.19", "JRNL TYPE.20", "JRNL TYPE.21", "JRNL TYPE.22", "JRNL TYPE.23", "JRNL TYPE.24", "JRNL TYPE.25"}),
    #"Changed Type6" = Table.TransformColumnTypes(#"Split Column by Delimiter5",{{"JRNL TYPE.1", type text}, {"JRNL TYPE.2", type text}, {"JRNL TYPE.3", type text}, {"JRNL TYPE.4", type text}, {"JRNL TYPE.5", type text}, {"JRNL TYPE.6", type text}, {"JRNL TYPE.7", type text}, {"JRNL TYPE.8", type text}, {"JRNL TYPE.9", type text}, {"JRNL TYPE.10", type text}, {"JRNL TYPE.11", type text}, {"JRNL TYPE.12", type text}, {"JRNL TYPE.13", type text}, {"JRNL TYPE.14", type text}, {"JRNL TYPE.15", type text}, {"JRNL TYPE.16", type text}, {"JRNL TYPE.17", type text}, {"JRNL TYPE.18", type text}, {"JRNL TYPE.19", type text}, {"JRNL TYPE.20", type text}, {"JRNL TYPE.21", type text}, {"JRNL TYPE.22", type text}, {"JRNL TYPE.23", type text}, {"JRNL TYPE.24", type text}, {"JRNL TYPE.25", type text}}),
    #"Split Column by Delimiter6" = Table.SplitColumn(#"Changed Type6","DATE",Splitter.SplitTextByDelimiter(" "),{"DATE.1", "DATE.2", "DATE.3", "DATE.4", "DATE.5", "DATE.6", "DATE.7", "DATE.8", "DATE.9", "DATE.10", "DATE.11", "DATE.12", "DATE.13", "DATE.14", "DATE.15", "DATE.16", "DATE.17", "DATE.18", "DATE.19", "DATE.20", "DATE.21", "DATE.22", "DATE.23", "DATE.24", "DATE.25"}),
    #"Changed Type7" = Table.TransformColumnTypes(#"Split Column by Delimiter6",{{"DATE.1", type date}, {"DATE.2", type text}, {"DATE.3", type text}, {"DATE.4", type text}, {"DATE.5", type text}, {"DATE.6", type text}, {"DATE.7", type text}, {"DATE.8", type text}, {"DATE.9", type text}, {"DATE.10", type text}, {"DATE.11", type text}, {"DATE.12", type text}, {"DATE.13", type text}, {"DATE.14", type text}, {"DATE.15", type text}, {"DATE.16", type text}, {"DATE.17", type text}, {"DATE.18", type text}, {"DATE.19", type text}, {"DATE.20", type text}, {"DATE.21", type text}, {"DATE.22", type text}, {"DATE.23", type text}, {"DATE.24", type text}, {"DATE.25", type text}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Changed Type7",{"AGME.CO.ID", "SCHED", "NAME", "NAME_1", "N-CD", "SALE CO.1", "SALE CO.2", "SALE CO.3", "SALE CO.4", "SALE CO.5", "SALE CO.6", "SALE CO.7", "SALE CO.8", "SALE CO.9", "SALE CO.10", "SALE CO.11", "SALE CO.12", "SALE CO.13", "SALE CO.14", "SALE CO.15", "SALE CO.16", "SALE CO.17", "SALE CO.18", "SALE CO.19", "SALE CO.20", "SALE CO.21", "SALE CO.22", "SALE CO.23", "SALE CO.24", "SALE CO.25", "REFER.1", "REFER.2", "REFER.3", "REFER.4", "REFER.5", "REFER.6", "REFER.7", "REFER.8", "REFER.9", "REFER.10", "REFER.11", "REFER.12", "REFER.13", "REFER.14", "REFER.15", "REFER.16", "REFER.17", "REFER.18", "REFER.19", "REFER.20", "REFER.21", "REFER.22", "REFER.23", "REFER.24", "REFER.25", "JRNL CO.1", "JRNL CO.2", "JRNL CO.3", "JRNL CO.4", "JRNL CO.5", "JRNL CO.6", "JRNL CO.7", "JRNL CO.8", "JRNL CO.9", "JRNL CO.10", "JRNL CO.11", "JRNL CO.12", "JRNL CO.13", "JRNL CO.14", "JRNL CO.15", "JRNL CO.16", "JRNL CO.17", "JRNL CO.18", "JRNL CO.19", "JRNL CO.20", "JRNL CO.21", "JRNL CO.22", "JRNL CO.23", "JRNL CO.24", "JRNL CO.25", "SO.1", "SO.2", "SO.3", "SO.4", "SO.5", "SO.6", "SO.7", "SO.8", "SO.9", "SO.10", "SO.11", "SO.12", "SO.13", "SO.14", "SO.15", "SO.16", "SO.17", "SO.18", "SO.19", "SO.20", "SO.21", "SO.22", "SO.23", "SO.24", "SO.25", "ODATE.1", "ODATE.2", "ODATE.3", "ODATE.4", "ODATE.5", "ODATE.6", "ODATE.7", "ODATE.8", "ODATE.9", "ODATE.10", "ODATE.11", "ODATE.12", "ODATE.13", "ODATE.14", "ODATE.15", "ODATE.16", "ODATE.17", "ODATE.18", "ODATE.19", "ODATE.20", "ODATE.21", "ODATE.22", "ODATE.23", "ODATE.24", "ODATE.25", "JRNL TYPE.1", "JRNL TYPE.2", "JRNL TYPE.3", "JRNL TYPE.4", "JRNL TYPE.5", "JRNL TYPE.6", "JRNL TYPE.7", "JRNL TYPE.8", "JRNL TYPE.9", "JRNL TYPE.10", "JRNL TYPE.11", "JRNL TYPE.12", "JRNL TYPE.13", "JRNL TYPE.14", "JRNL TYPE.15", "JRNL TYPE.16", "JRNL TYPE.17", "JRNL TYPE.18", "JRNL TYPE.19", "JRNL TYPE.20", "JRNL TYPE.21", "JRNL TYPE.22", "JRNL TYPE.23", "JRNL TYPE.24", "JRNL TYPE.25", "CONTROL", "DATE.1", "DATE.2", "DATE.3", "DATE.4", "DATE.5", "DATE.6", "DATE.7", "DATE.8", "DATE.9", "DATE.10", "DATE.11", "DATE.12", "DATE.13", "DATE.14", "DATE.15", "DATE.16", "DATE.17", "DATE.18", "DATE.19", "DATE.20", "DATE.21", "DATE.22", "DATE.23", "DATE.24", "DATE.25", "DATE_2", "A-ACCT", "NAME_3", "CONTROL_4", "CONTROL2"}),
    #"Removed Columns1" = Table.RemoveColumns(#"Reordered Columns",{"DATE_2", "A-ACCT", "NAME_3", "CONTROL_4", "CONTROL2"}),
    #"Reordered Columns1" = Table.ReorderColumns(#"Removed Columns1",{"AGME.CO.ID", "SCHED", "NAME", "NAME_1", "N-CD", "CONTROL", "SALE CO.1", "SALE CO.2", "SALE CO.3", "SALE CO.4", "SALE CO.5", "SALE CO.6", "SALE CO.7", "SALE CO.8", "SALE CO.9", "SALE CO.10", "SALE CO.11", "SALE CO.12", "SALE CO.13", "SALE CO.14", "SALE CO.15", "SALE CO.16", "SALE CO.17", "SALE CO.18", "SALE CO.19", "SALE CO.20", "SALE CO.21", "SALE CO.22", "SALE CO.23", "SALE CO.24", "SALE CO.25", "REFER.1", "REFER.2", "REFER.3", "REFER.4", "REFER.5", "REFER.6", "REFER.7", "REFER.8", "REFER.9", "REFER.10", "REFER.11", "REFER.12", "REFER.13", "REFER.14", "REFER.15", "REFER.16", "REFER.17", "REFER.18", "REFER.19", "REFER.20", "REFER.21", "REFER.22", "REFER.23", "REFER.24", "REFER.25", "JRNL CO.1", "JRNL CO.2", "JRNL CO.3", "JRNL CO.4", "JRNL CO.5", "JRNL CO.6", "JRNL CO.7", "JRNL CO.8", "JRNL CO.9", "JRNL CO.10", "JRNL CO.11", "JRNL CO.12", "JRNL CO.13", "JRNL CO.14", "JRNL CO.15", "JRNL CO.16", "JRNL CO.17", "JRNL CO.18", "JRNL CO.19", "JRNL CO.20", "JRNL CO.21", "JRNL CO.22", "JRNL CO.23", "JRNL CO.24", "JRNL CO.25", "SO.1", "SO.2", "SO.3", "SO.4", "SO.5", "SO.6", "SO.7", "SO.8", "SO.9", "SO.10", "SO.11", "SO.12", "SO.13", "SO.14", "SO.15", "SO.16", "SO.17", "SO.18", "SO.19", "SO.20", "SO.21", "SO.22", "SO.23", "SO.24", "SO.25", "ODATE.1", "ODATE.2", "ODATE.3", "ODATE.4", "ODATE.5", "ODATE.6", "ODATE.7", "ODATE.8", "ODATE.9", "ODATE.10", "ODATE.11", "ODATE.12", "ODATE.13", "ODATE.14", "ODATE.15", "ODATE.16", "ODATE.17", "ODATE.18", "ODATE.19", "ODATE.20", "ODATE.21", "ODATE.22", "ODATE.23", "ODATE.24", "ODATE.25", "JRNL TYPE.1", "JRNL TYPE.2", "JRNL TYPE.3", "JRNL TYPE.4", "JRNL TYPE.5", "JRNL TYPE.6", "JRNL TYPE.7", "JRNL TYPE.8", "JRNL TYPE.9", "JRNL TYPE.10", "JRNL TYPE.11", "JRNL TYPE.12", "JRNL TYPE.13", "JRNL TYPE.14", "JRNL TYPE.15", "JRNL TYPE.16", "JRNL TYPE.17", "JRNL TYPE.18", "JRNL TYPE.19", "JRNL TYPE.20", "JRNL TYPE.21", "JRNL TYPE.22", "JRNL TYPE.23", "JRNL TYPE.24", "JRNL TYPE.25", "DATE.1", "DATE.2", "DATE.3", "DATE.4", "DATE.5", "DATE.6", "DATE.7", "DATE.8", "DATE.9", "DATE.10", "DATE.11", "DATE.12", "DATE.13", "DATE.14", "DATE.15", "DATE.16", "DATE.17", "DATE.18", "DATE.19", "DATE.20", "DATE.21", "DATE.22", "DATE.23", "DATE.24", "DATE.25"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Reordered Columns1", {"AGME.CO.ID", "SCHED", "NAME", "NAME_1", "N-CD", "CONTROL"}, "Attribute", "Value"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Columns",".*","",Replacer.ReplaceText,{"Attribute"}),
    #"Split Column by Delimiter7" = Table.SplitColumn(#"Replaced Value","Attribute",Splitter.SplitTextByDelimiter("."),{"Attribute.1", "Attribute.2"}),
    #"Changed Type8" = Table.TransformColumnTypes(#"Split Column by Delimiter7",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}}),
    #"Removed Columns2" = Table.RemoveColumns(#"Changed Type8",{"Attribute.2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns2",{{"Attribute.1", "Type"}}),
    #"Removed Columns3" = Table.RemoveColumns(#"Renamed Columns",{"SCHED", "NAME", "NAME_1", "N-CD"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns3",{{"AGME.CO.ID", "companyid"}, {"CONTROL", "control"}}),
    #"Reordered Columns2" = Table.ReorderColumns(#"Renamed Columns1",{"companyid", "control", "Type", "Value"})
    in
    #"Reordered Columns2"
    I need to do one more transform which is a Pivot like so:
    #"Pivoted Column" = Table.Pivot(#"Reordered Columns2", List.Distinct(#"Reordered Columns2"[Type]), "Type", "Value")
    in
    #"Pivoted Column"
    and I only get 326 rows. Because it is a pivot without aggregation I get errors but even if I remove errors I still don't get the complete result set.
    Any ideas?

    Hello again and thanks for your help. I used List.First because the value column is text however I only got one row returned so I thought I would give you all my code (because I changed some things to make it simpler) and some pictures. Here's my code:
    let
    Source = Csv.Document(File.Contents("C:\Users\jdonnelly\Desktop\2014 JW Annual Review\ALL STORES 01-07-15 AR OPEN.csv"),null,",",null,1252),
    #"First Row as Header" = Table.PromoteHeaders(Source),
    #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"AR-OPEN", type text}, {"SALE CO", type text}, {"NAME", type text}, {"N-CD", Int64.Type}, {"REFER", type text}, {"JRNL CO", type text}, {"SCHED", type text}, {"AGME.CO.ID", Int64.Type}, {"SO", type text}, {"ODATE", type text}, {"JRNL TYPE", type text}, {"CONTROL", type text}, {"DATE", type text}, {"A-ACCT", type text}, {"CONTROL2", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"AR-OPEN", "NAME", "NAME_1", "N-CD", "JRNL CO", "SCHED", "AGME.CO.ID", "JRNL TYPE", "DATE", "DATE_2", "A-ACCT", "NAME_3", "CONTROL_4", "CONTROL2"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"CONTROL", "SALE CO", "REFER", "SO", "ODATE"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Reordered Columns","ODATE",Splitter.SplitTextByDelimiter(" "),{"ODATE.1", "ODATE.2", "ODATE.3", "ODATE.4", "ODATE.5", "ODATE.6", "ODATE.7", "ODATE.8", "ODATE.9", "ODATE.10", "ODATE.11", "ODATE.12", "ODATE.13", "ODATE.14", "ODATE.15", "ODATE.16", "ODATE.17", "ODATE.18", "ODATE.19"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"ODATE.1", type date}, {"ODATE.2", type text}, {"ODATE.3", type text}, {"ODATE.4", type text}, {"ODATE.5", type text}, {"ODATE.6", type text}, {"ODATE.7", type text}, {"ODATE.8", type text}, {"ODATE.9", type text}, {"ODATE.10", type text}, {"ODATE.11", type text}, {"ODATE.12", type text}, {"ODATE.13", type text}, {"ODATE.14", type text}, {"ODATE.15", type text}, {"ODATE.16", type text}, {"ODATE.17", type text}, {"ODATE.18", type text}, {"ODATE.19", type text}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Changed Type1",{"ODATE.2", "ODATE.3", "ODATE.5", "ODATE.6", "ODATE.8", "ODATE.9", "ODATE.11", "ODATE.12", "ODATE.14", "ODATE.15", "ODATE.17", "ODATE.18"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Removed Columns1",{{"ODATE.1", type date}, {"ODATE.4", type date}, {"ODATE.7", type date}, {"ODATE.10", type date}, {"ODATE.13", type date}, {"ODATE.16", type date}, {"ODATE.19", type date}}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Changed Type2","SO",Splitter.SplitTextByDelimiter(" "),{"SO.1", "SO.2", "SO.3", "SO.4", "SO.5", "SO.6", "SO.7", "SO.8", "SO.9", "SO.10", "SO.11", "SO.12", "SO.13", "SO.14", "SO.15", "SO.16", "SO.17", "SO.18", "SO.19"}),
    #"Changed Type3" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"SO.1", Int64.Type}, {"SO.2", type text}, {"SO.3", type text}, {"SO.4", type text}, {"SO.5", type text}, {"SO.6", type text}, {"SO.7", type text}, {"SO.8", type text}, {"SO.9", type text}, {"SO.10", type text}, {"SO.11", type text}, {"SO.12", type text}, {"SO.13", type text}, {"SO.14", type text}, {"SO.15", type text}, {"SO.16", type text}, {"SO.17", type text}, {"SO.18", type text}, {"SO.19", type text}}),
    #"Removed Columns2" = Table.RemoveColumns(#"Changed Type3",{"SO.2", "SO.3", "SO.5", "SO.6", "SO.8", "SO.9", "SO.11", "SO.12", "SO.14", "SO.15", "SO.17", "SO.18"}),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Removed Columns2","REFER",Splitter.SplitTextByDelimiter(" "),{"REFER.1", "REFER.2", "REFER.3", "REFER.4", "REFER.5", "REFER.6", "REFER.7", "REFER.8", "REFER.9", "REFER.10", "REFER.11", "REFER.12", "REFER.13", "REFER.14", "REFER.15", "REFER.16", "REFER.17", "REFER.18", "REFER.19"}),
    #"Changed Type4" = Table.TransformColumnTypes(#"Split Column by Delimiter2",{{"REFER.1", type text}, {"REFER.2", type text}, {"REFER.3", type text}, {"REFER.4", type text}, {"REFER.5", type text}, {"REFER.6", type text}, {"REFER.7", type text}, {"REFER.8", type text}, {"REFER.9", type text}, {"REFER.10", type text}, {"REFER.11", type text}, {"REFER.12", type text}, {"REFER.13", type text}, {"REFER.14", type text}, {"REFER.15", type text}, {"REFER.16", type text}, {"REFER.17", type text}, {"REFER.18", type text}, {"REFER.19", type text}}),
    #"Removed Columns3" = Table.RemoveColumns(#"Changed Type4",{"REFER.2", "REFER.3", "REFER.5", "REFER.6", "REFER.8", "REFER.9", "REFER.11", "REFER.12", "REFER.14", "REFER.15", "REFER.17", "REFER.18"}),
    #"Split Column by Delimiter3" = Table.SplitColumn(#"Removed Columns3","SALE CO",Splitter.SplitTextByDelimiter(" "),{"SALE CO.1", "SALE CO.2", "SALE CO.3", "SALE CO.4", "SALE CO.5", "SALE CO.6", "SALE CO.7", "SALE CO.8", "SALE CO.9", "SALE CO.10", "SALE CO.11", "SALE CO.12", "SALE CO.13", "SALE CO.14", "SALE CO.15", "SALE CO.16", "SALE CO.17", "SALE CO.18", "SALE CO.19"}),
    #"Changed Type5" = Table.TransformColumnTypes(#"Split Column by Delimiter3",{{"SALE CO.1", Int64.Type}, {"SALE CO.2", type text}, {"SALE CO.3", type text}, {"SALE CO.4", type text}, {"SALE CO.5", type text}, {"SALE CO.6", type text}, {"SALE CO.7", type text}, {"SALE CO.8", type text}, {"SALE CO.9", type text}, {"SALE CO.10", type text}, {"SALE CO.11", type text}, {"SALE CO.12", type text}, {"SALE CO.13", type text}, {"SALE CO.14", type text}, {"SALE CO.15", type text}, {"SALE CO.16", type text}, {"SALE CO.17", type text}, {"SALE CO.18", type text}, {"SALE CO.19", type text}}),
    #"Removed Columns4" = Table.RemoveColumns(#"Changed Type5",{"SALE CO.2", "SALE CO.3", "SALE CO.5", "SALE CO.6", "SALE CO.8", "SALE CO.9", "SALE CO.11", "SALE CO.12", "SALE CO.14", "SALE CO.15", "SALE CO.17", "SALE CO.18"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Removed Columns4", {}, "Attribute", "Value"),
    #"Changed Type6" = Table.TransformColumnTypes(#"Unpivoted Columns",{{"Value", type text}}),
    #"Split Column by Delimiter4" = Table.SplitColumn(#"Changed Type6","Attribute",Splitter.SplitTextByDelimiter("."),{"Attribute.1", "Attribute.2"}),
    #"Changed Type7" = Table.TransformColumnTypes(#"Split Column by Delimiter4",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
    #"Removed Columns5" = Table.RemoveColumns(#"Changed Type7",{"Attribute.2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns5",{{"Attribute.1", "Attribute"}})
    #"Pivoted Column" = Table.Pivot(#"Renamed Columns", List.Distinct(#"Renamed Columns"[Attribute]), "Attribute", "Value", List.First)
    in
    #"Pivoted Column"
    Before the Table.Pivot my View is as follows:
    It runs down to row 18,200 or so. I chose a smaller file to make things simpler.
    After the Table.Pivot as written above this is what my view shows:
    So I received only one row. Is there a way to make it all rows?
    (For background: the CSV file is from a PICK database that has multi-variate fields where all but one of the fields has multiple values correlated with multiple values in other fields.)
    Thanks again
    John Donnelly

  • How to valuate efficiency of aggregates (in time of query run)

    Hi, all!
    Is there simple way to learn query execution time? I'd like to use it for valuating aggregates efficiency.
    I know that it can be done by looking at BW Stat tables, but  it is not comfortable. Maybe there is an option in rsrt to show total run time, without using cache?

    You can use RSRT to compare query results with and without the aggregate.  Use the Execute & Debug option when you go to run your query. Then near the of the Debug options under Others, is an option to Display BW Statistics.  Tihs option will display the components of the run time time and how many rows were read and how many were transferred to the OLAP processor. 
    Near the top of the the Debug options is the option Do Not Use Aggregates, so you can run the same query using the aggregates and then again without the aggregates and compare the results.
    Couple of important items -
    This is only testing one particular execution with the inputs you provide.  If the query you are testing has many input prompts and many free characteristics, your users could be running the query in very different ways than your test.
    Your primary interest in this test is the DB time which should pretty strongly correlate with the number of rows selected (read). The total RSRT time shouldn't be worried about for evaluating impact of an aggregate because the front end time should generally be the same regardless of use of the aggregate, since it is a function of the time it takes to get the data to the client and formatted, which should be the same since you are moving the same data to the client with the aggregate and without the aggregate.
    RSRT also has the Debug option Display Run Schedule, which will providew the database optimziers Explain (Execution) Plan which you could also use to evalue the query's performance with and without the aggregate.
    Before starting, you should make sure the DB statistics for the base cube and the aggregate are current in order to provide a valid comparison.
    Also, when using RSRT, keep in mind, that if the query is against an Infocube that has data in both the E and F fact tables, two SQL queries really run, and RSRT will show two Explain plans if you have the Disaply Run Schedule option checked.  If the query is against the multiprovider, you will have SQL queries against each underlying Infoprovider and Explain Plans for each.

  • Splits for aggregates in rsrt

    When I go to RSRT and execute+debug my query, with aggregates selected, it shows splits like split1, split2 etc. What does the split mean?

    Each split is like a small sub-query telling you the parameters used in that particular part of the query. Depending on how your aggregates are set up then one aggregate may be sufficient for a number of 'splits'.
    If you have 'Fixed' parameters on then you may find an aggregate is sufficient for most splits but if you have values hard coded then the aggregate is less likely to be useful for many splits.
    You need to find a balance between putting in place appropriate aggregates, without building aggregates that are so big they become almost useless.
    The number of splits you see in RSRT is determined by your query definition, not by your aggregates.
    Hope I have understood your question
    Dave

  • Difference between Switch -off and disable of an aggregate.

    Hi All,
    Can any one please tell me whats the difference between Switch-off and Disable an aggregate?
    Appreciate ur help.
    Thanks,
    Soumya.

    Hi,
    You can temporarily switch off an aggregate to check if you need to use it. An aggregate that is switched off is not used when a query is executed.
    To do this select the relevant aggregate and choose This graphic is explained in the accompanying text Switch On/Off. An aggregate that is switched off is marked in column Filled/Switched off with This graphic is explained in the accompanying text.
    Since aggregates that are switched off must also be consistent, you do not have to activate the aggregate again or to fill it when you switch it back on.
    Execute a query or trace that would use the aggregate that was switched off. Compare the time that the database needs with the time that the query needs when using the aggregate. If the query is not significantly slower without the aggregate, you can deactivate or delete the aggregate.
    The system deletes all the data and database tables of an aggregate. The definition of the aggregate is not deleted.
    Deactivation
    Select the required aggregate and choose This graphic is explained in the accompanying text Deactivate.
    The status display in the columns Status and Filled/switched off change back to This graphic is explained in the accompanying text.
    If you want to, you can activate and fill the aggregate again later.
    More information:
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/26/4bc0417951d117e10000000a155106/frameset.htm
    Hope it helps.
    Regards,
    Ray

  • Max Qty of serial number without duplicated.

    I have Query
    SELECT Serial,Itemcode,ItemName,Storecode,factor,pckqty,qty,'' "varient in PCS"
    FROM s_products where storecode='MEENA'   GROUP BY Itemcode,Serial,ItemName,Storecode,factor,pckqty,qty,Expirydate 
    HAVING max(qty)>=0 order by Itemcode,qty desc
    Out Put
    1999114901 00021002
    SKIMMED MILK POWDER(SUN GOLD) 1X25 KGS
    MEENA 1
    25.0 10
    1999116694 00021002
    SKIMMED MILK POWDER(SUN GOLD) 1X25 KGS
    MEENA 1
    25.0 15
    1999128618 00021002
    SKIMMED MILK POWDER(SUN GOLD) 1X25 KGS
    MEENA 1
    25.0 5
    199955917 00021002
    SKIMMED MILK POWDER(SUN GOLD) 1X25 KGS
    MEENA 1
    25.0 6
    199939288 00021003
    SKIMMED MILK POWDER(BEST WAY) 1X25 KGS
    MEENA 1
    25.0 7
    199942411 00021003
    SKIMMED MILK POWDER(BEST WAY) 1X25 KGS
    MEENA 1
    25.0 5
    199995867 00021003
    SKIMMED MILK POWDER(BEST WAY) 1X25 KGS
    MEENA 1
    25.0 7
    1999111344 00021004
    FULL CREAM MILK POWDER (BESTWAY) 1X25 KG
    MEENA 1
    25.0 0.0
    1999123982 00021004
    FULL CREAM MILK POWDER (BESTWAY) 1X25 KG
    MEENA 1
    25.0 0.0
    1999156247 00021004
    FULL CREAM MILK POWDER (BESTWAY) 1X25 KG
    MEENA 1
    25.0 0.0
    1999172210 00021004
    FULL CREAM MILK POWDER (BESTWAY) 1X25 KG
    MEENA 1
    25.0 0.0
    Iwant the Out like 
    1999116694 00021002
    SKIMMED MILK POWDER(SUN GOLD) 1X25 KGS
    MEENA 1
    25.0 15
    199995867 00021003
    SKIMMED MILK POWDER(BEST WAY) 1X25 KGS
    MEENA 1
    25.0 7
    1999172210 00021004
    FULL CREAM MILK POWDER (BESTWAY) 1X25 KG
    MEENA 1
    25.0 0.0
    Tips Hiegst Qty ,Without duplicating ItemCode,Heighest Serial number ways record in above order
    AK

    MAX does this.  Instead of grouping by the serial, use MAX(Serial)
    SELECT Max(Serial),Itemcode,ItemName,Storecode,factor,pckqty,qty,'' "varient in PCS"
    FROM s_products where storecode='MEENA'   GROUP BY Itemcode,ItemName,Storecode,factor,pckqty,qty,Expirydate 
    HAVING max(qty)>=0 order by Itemcode,qty desc
    In fact, without an aggregate in your query, group by does absolutely nothing.
    This assumes that Serial is the column you only want the max value from.  You seem to say that, but the data you posted, makes me think that is not true.  Your SQL also has a random string in it, and appears to be missing some values, so there's
    general issues there, but my answer is correct, it's just that the starting SQL was not correct.
    And you're saying that the qty can be negative ?
    Christian Graus

  • How to get Average of a column in UNION query

    Hi All,
    I will try to explain the issue as much as I can and If you need clarification on any piece please let me know.
    So, I have a Union Query with two sets of Criteria.
    The first Criteria Brings the list of Buildings and a set of Measures for it. The second criteria does the same but with a different set of filters.
    No I use a UNION between these both criteria and present them in a Pivot view so that we only have one row per each building. The values in each of the criteria in the UNION query are Summed
    Ex:
    Building
    Metric 1
    Metric 2
    1
    20
    30
    1
    25
    35
    2
    40
    50
    2
    45
    55
    So as I show in the pivot the result is
    Building
    Metric 1
    Metric 2
    1
    45
    65
    2
    85
    105
    Now the issue is with the Grand Total.
    I want the Grand Total to be an Average of the Buildings. So for Metric 1 The Grand Total should be (45+85)/2 because we have two buildings so the answer should be 65.
    How can I get that.
    Bottom Line: Need an Average as the Grand Total when the Aggregation rule on the column is set to Sum.
    we use 11.1.6.10 version

    Hi VJ
    What you are asking is impossible in the pivot table itself as you are asking one part of the pivot table to aggregate via one method, and another to aggregate via another method, on the same column ..
    It can be done using a calculated item. For your example above you'd use the formula ( $1 + $2) / 2.
    .. But thats HIGHLY explicit, and would only work if you KNOW how many buildings will come back in the query.. EVERYTIME.
    Why not restructure the query to combine it into a single query using an combinations of filters with OR in between?

  • MS-Access query running very slow

    Hi,
    We've MS-Access application which was pointing to UDB. Now we migrated it to point Oracle DB 9.2. After migration some of the query is running very slow.
    These queries used to take less than 30 seconds in UDB now taking more than 5 Minutes in Oracle.
    some more obeservation :
    (1) Some of the queries using "HAVING" clause without any aggregate function. When I moved this condition to "WHERE" clause, performance improved a lot.
    But problem is that I can't suggest this solution to "USERS". They are creating query using "query wizard" in MS-Access and they started creating noise on this.
    (2) I tested same MDB in two different PCs and same query is returning records in 4 seconds in one system, is taking more than 10 minutes in other system.
    Since I'm new to MS-Access, I don't know what other information I need to provide here.
    Please help me out.

    I have seen the problem like this,too
    can i have you

Maybe you are looking for

  • Why am I unable to sync Photostream to Iphone and Ipad?

    Hello, In the past, Photostream would automatically sync all recent photos from my IPhone 4S and Ipad mini to my laptop (windows 8). Since upgrading to the IPhone 6 in September, photos have not been uploading. I have tried reinstalling icloud, chang

  • States in graphic styles

    Hi I tried to use graphic styles to save  the states of an menu-enty or a input field - and failed. So it's not possible to safe different states in one graphic style?

  • RDP 6.0 Vista lefthand Mouse doesn't work

    When i connect to a Terminal client  with my Windows Vista my left hand lefthand Mouse doesn't work correctly (switch to right hand). With Windows XP and RDP 6.0 i haven't these problem. what goes wrong? Regards Walter

  • Can I use dual monitors in Premiere Elements 10?

    I've been using Vegas Movie Studio until now. And I wonder if I even in Premiere Elements can use dual monitors. Not just to pull over the viewing part of a screen. But watch the movie in a small window on one screen with the timeline and still have

  • 10.5.7 Update not showing in Installed Updates log

    Hello everyone! Not sure if this is some type of problem or not but I'm checking with you guys before I do something drastic like reinstall Leopard or something. I installed the 10.5.7 update yesterday on my iBook G4. After I installed it, the comput