Using Group by SQL Issues tab?

Hi All,
Is this SQl possible in the Advanced tab:
SELECT T1.saw_0 saw_0, sum(T1.saw_2) saw_1 FROM (SELECT TEST_CUSTOMER.CUSTOMER saw_0, TEST_CAL_DIM.TIME_ID saw_1, SUM(TEST_CAL_DIM.CAL_DAYS) / COUNT(TEST_CAL_DIM.TIME_ID) saw_2 FROM TestforBalance_Sree ORDER BY saw_0, saw_1) T1 group by saw_1 ORDER BY saw_0

Have a look here:
http://obiee101.blogspot.com/2010/01/obiee-aggregate-by-part-2.html
regards
John
http://obiee101.blogspot.com

Similar Messages

  • Set filter (with presentation variables) for requests using "SQL Issued"

    if I have a "SQL issued":
    SELECT saw_0 saw_0, saw_1 saw_1, saw_2 saw_2, saw_3 saw_3, saw_4 saw_4 FROM (
    SELECT saw_0 saw_0, saw_1 saw_1, SUM(saw_2) saw_2, SUM(saw_3) saw_3, SUM(saw_4) saw_4
    FROM
    SELECT "Period"."YearMonth" saw_0, "Customer"."CustomerName" saw_1, COUNT("Sales"."SalesDate") saw_2, "Sales"."No.OfConsumer" saw_3, 0 saw_4
    FROM CRM
    WHERE ("Period"."YearMonth" >= 200904) AND ("Period"."YearMonth" <= 200910)
    UNION ALL
    SELECT "Period"."YearMonth" saw_0, "Customer"."CustomerName" saw_1, 0 saw_2, 0 saw_3, Count("SuperSales"."SuperSalesDate") saw_4
    FROM CRM
    WHERE ("Period"."YearMonth" >= 200904) AND ("Period"."YearMonth" <= 200910)
    ) t1
    GROUP BY saw_0, saw_1
    ORDER BY saw_0, saw_1
    ) t2 ORDER BY saw_0
    actually, in this request, I would like to set a filter for "Period"."YearMonth" using presentation variable.
    is it possible to do this ?
    Thanks !!

    Hi Forreging,
    You can use presentation variables, but not if you are directly setting the SQL via the Advanced tab.
    Instead, build up the first report just like the first part of the UNION statement. Then use the "Combine with Similar request" to build up the logic for the second part of the query.
    When you approach it this way, you have the ability to set filters on each "Sub-Request" via the Criteria tab. Otherwise, OBIEE only lets you add a filter at the outer level of the query when you go the route of setting the SQL in the Advanced tab.
    Good luck and if you find this post useful, please award points!
    Best regards,
    -Joe

  • Isse with using Grouping Sets in SQL Server 2008 R2

    Hi,
    I created a query in SQL Server 2012 using grouping sets that works fine.  When I try to use the same query in SQL Server 2008 I get an error ("Inccorrect syntax near SETS").
    I researched using grouping sets in 2008 and didn't see any issue with my query.  What is different in grouping sets 2008 vs 2012?
    SELECT tl.ClientRegionCd as [Client Region Code] , tl.ClientRegionDesc as [Region Name], count(tl.CompleteICN) as [Trauma Letters Sent]
    from TORT_Trauma_Letters tl
    Where CONVERT(VARCHAR(26), tl.SecondNoticeSent, 23) between '2014-06-12' and '2014-06-12'
    GROUP BY GROUPING SETS((tl.ClientRegionCd, tl.ClientRegionDesc), ())
    Stacie

    Check this blog post as how to deal with date ranges
    http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/16/bad-habits-to-kick-mishandling-date-range-queries.aspx
    For your result you can simply achieve your result with UNION ALL, e.g.
    select Client, Region, Letters
    from myTable 
    UNION ALL
    select NULL, NULL, SUM(letters) as Letters
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • How to write a SQL Query without using group by clause

    Hi,
    Can anyone help me to find out if there is a approach to build a SQL Query without using group by clause.
    Please site an example if is it so,
    Regards

    I hope this example could illuminate danepc on is problem.
    CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
    CREATE OR REPLACE FUNCTION GET_ARR return my_array
    as
         arr my_array;
    begin
         arr := my_array();
         for i in 1..10 loop
              arr.extend;
              arr(i) := i mod 7;
         end loop;
         return arr;
    end;
    select column_value
    from table(get_arr)
    order by column_value;
    select column_value,count(*) occurences
    from table(get_arr)
    group by column_value
    order by column_value;And the output should be something like this:
    SQL> CREATE or replace TYPE MY_ARRAY AS TABLE OF INTEGER
      2  /
    Tipo creato.
    SQL>
    SQL> CREATE OR REPLACE FUNCTION GET_ARR return my_array
      2  as
      3   arr my_array;
      4  begin
      5   arr := my_array();
      6   for i in 1..10 loop
      7    arr.extend;
      8    arr(i) := i mod 7;
      9   end loop;
    10   return arr;
    11  end;
    12  /
    Funzione creata.
    SQL>
    SQL>
    SQL> select column_value
      2  from table(get_arr)
      3  order by column_value;
    COLUMN_VALUE
               0
               1
               1
               2
               2
               3
               3
               4
               5
               6
    Selezionate 10 righe.
    SQL>
    SQL> select column_value,count(*) occurences
      2  from table(get_arr)
      3  group by column_value
      4  order by column_value;
    COLUMN_VALUE OCCURENCES
               0          1
               1          2
               2          2
               3          2
               4          1
               5          1
               6          1
    Selezionate 7 righe.
    SQL> Bye Alessandro

  • Import Excel file into SQL, using bulk copy - date issues

    Hello. I have a VB project where I need to import multiple excel files with lots of rows and columns into SQL 2012. Currently the import is set up, using OleDbConnection and insert commands and it takes up to 10 minutes to process all the spreadsheets.
    I'm trying to switch the code to use SQLBulkCopy, but experienced issues with dates columns. Some rows have Null dates and those are interpreted as strings and won't import into SQL tables. Is there a way to format the column prior to import programmatically?
    Any advice is appreciated.
    Note -
    If I add column mapping and exclude all dates columns - import works fine. All excel files have date fields, excel files are reports from other vendor and change on weekly bases, manual formatting of the excel files prior to import are out of the question...
    The code is just basic:
    Public Sub ImportFormExcelSample()
    Dim ExcelConnection As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\MyExcelSpreadsheet.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=Yes""")
    ExcelConnection.Open()
    Dim expr As String = "SELECT * FROM [Sheet1$]"
    Dim objCmdSelect As OleDbCommand = New OleDbCommand(expr, ExcelConnection)
    Dim objDR As OleDbDataReader
    Dim SQLconn As New SqlConnection()
    Dim ConnString As String = "Data Source=MMSQL1;Initial Catalog=DbName; User Id=UserName; Password=password;"
    SQLconn.ConnectionString = ConnString
    SQLconn.Open()
    Using bulkCopy As SqlBulkCopy = New SqlBulkCopy(SQLconn)
    bulkCopy.DestinationTableName = "TableToWriteToInSQLSERVER"
    Try
    objDR = objCmdSelect.ExecuteReader
    bulkCopy.WriteToServer(objDR)
    objDR.Close()
    SQLconn.Close()
    Catch ex As Exception
    MsgBox(ex.ToString)
    End Try
    End Using
    End Sub
    The error I get is System.InvalidOperatiomException: The given value of type String from the data source cannot be converted to type date of the specified target column. System.FormatException: Failed to convert parameter value from String to a DateTime...
    Thank you!
    Alla Sanders

    Hi Alla,
    This issue might be caused because the field contains a NULL value, but the date/time columns in your table does not allow NULL values. Furthermore, please aslo take a look at "Data Type Issues" session in the article below:
    http://odetocode.com/blogs/scott/archive/2013/02/08/working-with-sqlbulkcopy.aspx
    Here is a similar thread about this topic for your reference, please see:
    http://social.technet.microsoft.com/Forums/sqlserver/en-US/2d99181c-fc2b-4caf-9530-3bd6ae1745f1/sqlbulkcopy-column-validation-not-working?forum=sqldataaccess
    If you have any feedback on our support, please click
    here.
    Regards,
    Elvis Long
    TechNet Community Support

  • How do get rid of a tab group without closing the tabs? How do I take tabs out of a group?

    I accidentally put all my tabs in one group. I'd like to get rid of the group without closing all the tabs in it; in other words, to undo putting all the tabs in one group. It would be useful to know how to remove a tab from a group without closing the tab, accidentally putting a tab in the wrong group will probably be a common error that needs to be easily undone.

    '' SisqB;''
    ''I searched about:config and found a listing of "stuff" under the S3 Downloads ''
    Can you take a snapshot of what you see?
    In order to better assist you with your issue please provide us with a screenshot. If you need help to create a screenshot, please see [[How do I create a screenshot of my problem?]]
    Once you've done this, attach the saved screenshot file to your forum post by clicking the '''Browse...''' button below the ''Post your reply'' box. This will help us to visualize the problem.
    Thank you!

  • Using Group Policy to Set Windows Font DPI size

    I was in need of a way to change the Windows 7 user interface to use the Font size of 100% (vs the default of 125%) for custom applications on our network.
    Many searches on the net did not provide an easy way to accomplish this via Group Policy. The font size is PER USER and not PER MACHINE.
    I found a method using Group policy preferences (GPP) to configure the Font DPI size and wanted to share it for others who might need to do the same...
    I created a new GPO for the users needing this font size and linked it to their OU. Then configured the following:
    User Configuration \ Preferences \ Registry (Right click and select NEW \ Registry Wizard)
    Configure the following DWORD key: HKEY_CURRENT_USER\Control Panel\Desktop\LogPixels
    Use the values as needed:
    00000060 (Small Font Size 100%)
    00000090 (Medium Font Size 125%)
    00000144 (Large Font Size 150%)
    I used 00000060 to set the Small Font Size of 100%. Gpupdate /force a test client machine, then logoff/logon and see the setting take effect.
    When users try to change the font size in via the control panel, the value will be overwritten the next time the group policy updates. Id even recommend preventing users from being able to change the font dpi with another GPO setting:
    User Configuration \ Policies \ Administrative Templates \ Control Panel \ Personalization \ Prohibit selection of visual style font size = Enable
    Just wanted to share this for anyone needing to change the Windows 7 default font DPI size en mass using Group Policy. We can thank Microsoft for not giving us a ADMX template for this issue!!!!
    Drumgod
    me

    User Configuration \ Policies \ Administrative Templates \ Control Panel \ Personalization \ Prohibit selection of visual
    style font size = Enable
    This policy setting states that it is supported on Windows Server 2003, Windows XP, and Windows 2000 operating
    systems only. 
    The description on this setting says that it disables the "Font size" drop-down list on the Appearance tab in Display Properties. This does not exist in Windows 7. I don't think the DPI setting you are talking about is the equivalent.
    The other setting is good to have enough. Thanks for the tip!

  • How to transfer the tables from one file group to another file group in SQL 2008.?

    Hello all,
    I have few issues regarding the transfer of the tables from one file group to another file group  in SQL 2008 and also How can we  backup
    and restore the particular database based on file group level.
    Let’s say I have a tables stored within the different FG. such as
    Tables                                                    
      File group
    Dimension tables                                              
                                                                     Primary
    Fact tables                                               
                                                                              FG1
               FG2…
    zzz_tables                                               
                                                                              DEFAULT_FG    
    dim.table1                                                                                                                          DEFAULT_FG
    dim.table2                                                                                                                          DEFAULT_FG
    Here all I want to transfer the dim.table1 ,dim.table2  from  DEFAULT_FG to the Primary File
    group .So is there simple methods for transfer the dim.table1,2  from one FG to another .I have tried somewhat but I couldn’t get the exact way .So if someone have better idea please share your knowledge that would be really appreciated.
    Secondly after moving those dim.table1 ,dim.table2 from DEFAULT_FG to Primary ,All I want to backup and restore the database only containing  the Primary and FG1,FG2… not
    a DEFAULT_FG.Is it possible or not.?
    Hope to hear from the one who knows better approach for this kind of task .Your simple help will be much appreciated.
    Regards,
    Anil Maharjan

    Well after all my full day research on this topic had paid off, I finally got the solution and am so happy to research on these things. It makes
    us feel really happy after all our research and hard work doesn't goes as waste.
    Finally I got what I am looking for and want to make sure that I am able to transfer the tables from DEFAULT_FG to another FG without tables
    having clustered index on that tables .
    With the help of the link below I finally got my solution where Roberto’s coded store procedure simply works for this.
    Really thanks to him for his great post and thanks to all for your response and your valuable time.
    http://gallery.technet.microsoft.com/scriptcenter/c1da9334-2885-468c-a374-775da60f256f
    Regards,
    Anil Maharjan

  • I can only use Flash Player in one tab at a time, only on Firefox.

    Recently, when I downloaded the new Flash Player, I can only use flash player in one tab at a time. This is only in firefox. I'll open youtube, and the visual and sound both play perfectly. I open up a new tab, begin using a flash website in that tab, and the youtube sound is quiet, only the visual continues to play. I need to multitask with flash sometimes, and this is a big problem for me. Help!

    By default, Flash 11.3 and higher will spin up a lot of distinct processes. You should be able to get quite a cacophony going.
    Have you ever done any troubleshooting that involves changing how Firefox works with plugin-container.exe or the Flash player's protected mode?
    Often it is helpful to disable hardware graphics acceleration in Firefox and in Flash:
    (A) In Firefox, un-check the box here and restart:
    orange Firefox button (or Tools menu) > Options > Advanced > General > "Use hardware acceleration when available"
    (B) In Flash, see this support article from Adobe: http://helpx.adobe.com/flash-player/kb/video-playback-issues.html#main_Solve_video_playback_issues
    Unrelated, but you can remove the Java Console extensions unless you are a Java developer (and even then, you probably don't need the old ones):
    orange Firefox button (or Tools menu) > Add-ons > Extensions category

  • How do I remove a node from Always on Availability Group in SQL 2012

    Hello I was wondering if anyone could tell me to remove a node from an AOG group in SQL 2012.  We currently have a two node Always on availability group and I need to replace one of the servers.  My plan is to bring the
    new server on to the group then remove the old server and I am having issues finding documentation on this.  Could someone explain how to do this or if it is even possible.
    Thanks

    After the new server is added to the cluster and the AG, remove the old one by first
    ALTER AVAILABILITY GROUP [YourAG]
    REMOVE REPLICA ON N'OldServer';
    Remove a Secondary Replica from an Availability Group
    Then evict the old server from the cluster with the cluster administrator or
    Remove-ClusterNode OldServer
    Remember to verify the quorum configuration after adding the new server and removing the old server.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • How to use GROUP BY  in ODI

    how to use GROUP BY in ODI tool

    Hi ,
    you can combine the insert stamt with the select ....so that in the target u will get a single line .....
    SQL&gt; select * from prop_details;
    PROPERTY RELAVANTD NOTICES
    10100 25-JAN-09 30
    10100 03-JAN-09 30
    10100 02-DEC-08 20
    10100 01-DEC-08 10
    10100 31-DEC-08 20
    10101 10-JAN-09 10
    10101 20-JAN-07 15
    10101 30-DEC-08 45
    10101 20-FEB-08 35
    10101 31-JAN-09 25
    10 rows selected.
    SQL&gt; select PROPERTY,max(RELAVANTDATE),SUM(NOTICES) from PROP_DETAILS GROUP BY P
    ROPERTY;
    PROPERTY MAX(RELAV SUM(NOTICES)
    10101 31-JAN-09 130
    10100 25-JAN-09 110
    SQL&gt;

  • How do I prevent firefox from switching tab groups when closing a tab?

    I really like the tab groups feature, as it helps cut down on the number of tabs I have open at once. The problem is that when I close a tab, I sometimes get shunted to another random tab group. It is then a pain to get back to where I was before. Is there a way to force Firefox to choose among the current tab group for a tab to open?

    This problem persists in Firefox 5.0 on all of my computers (Windows 7, OS X 10.6, and *any* Linux distro). It would be nice if Firefox was forced to remain within a single tab group until no more tabs remain. Also, if we have pinned tabs, closing the last non-pinned tab should select the nearest pinned tab, without switching tab groups.
    This issue is pretty annoying. It would be nice to see a remedy. For reference, here is another post with the same issue: http://support.mozilla.com/en-US/questions/828677

  • ORacle sales analyzer doesn't display sql's using show sq.sql.stmts

    Hi,
    I cannot view the sql statements generated by Oracle Sales analyzer cube using show sq.sql.stmts.
    Moreover when I check on db I don't see any sql's being issued by web OSA session.
    What could be the possible reason for this?

    Lang wrote:
    Hi
    Can anyone help please, I am using SQL developer 3.0, and I have come across a lot of cases that after compiling a package , the compiler doesn't show me any errors, and It shows me the package is compiled , but it 's not valid after I close down the sql developer and log back in again.
    I am using 11g instantclient with it.Really?
    & here I thought SQL Developer used JDBC Thin to connect to the DB.

  • Uninstall Lync 2010 client, Install Lync 2013 using Group Policy/VB/MS Customisation Tool

    Hi, I am using Group Policy/vb/Lync customization tools to deploy 2013 and remove 2010. The machines have Office 2010. The vb script is as below:
    Dim objShell 'As Object
    Dim objFSO 'As FileSystemObject
    '-- SET OBJECTS
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objShell = CreateObject("WScript.Shell")
    strComputerName = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
    Dim WshNetwork : Set WshNetwork = WScript.CreateObject("WScript.Network")
    objShell.Run """\\xxxxxxxxx - Do not Remove\Lync Install 2013 2010\Lync 2013 Outlook 2010\setup.exe"""
    I have amended the OCT with relevant settings, Lync 2013 installs but Lync 2010 does not uninstall. Here is how i have it set:
    In the Office Customization Tool - Set-up - Add Installation and Run Programs,
    In target - pointing to the Lync2010 exe file (on above share)
    In Arguments - /silent /uninstall
    Is this correct?
    Also, i would have thought that, Remove Previous Installations, it would have an option to remove Lync2010?
    Anyway..pulling my hair out here!
    Hope you can help.

    Hi,
    Based on your description, we can refer to the following threads for help.
    Slient Unninstall of Lync 2010 on client machines script required
    http://social.technet.microsoft.com/Forums/lync/en-US/69e32128-4581-4be5-9a44-b5d133e1f480/slient-unninstall-of-lync-2010-on-client-machines-script-required
    Scripting a Lync 2010 client Uninstall
    http://social.technet.microsoft.com/Forums/en-US/a65bd0d0-daa1-4616-8725-63f349fdde86/scripting-a-lync-2010-client-uninstall?forum=lyncconferencing
    For this issue is more related to Lync, in order to get better help, we can ask the question in the following TechNet dedicated Lync forum.
    Lync 2010 and OCS - Lync Clients and Devices
    http://social.technet.microsoft.com/Forums/lync/en-US/home?forum=ocsclients&filter=alltypes&sort=lastpostdesc
    In addition, for it also involves scripts, we can also ask for help in the following scripting forum.
    The Official Scripting Guys Forum
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG&filter=alltypes&sort=lastpostdesc
    Hope it helps.
    Best regards,
    Frank Shen

  • Workaround for opening a strongly typed cursor using native dynamic SQL

    Hi All,
    In reading the PL/SQL documentation for Oracle 9i, I noted that the OPEN-FOR
    statement with a dynamic SQL string only allows the use of weakly typed cursors.
    I have verified this limitation with my own experimentation as follows:
    DECLARE
    type rec_type is record(
    str     varchar2(40),
    num     number(22)
    type cur_type is ref cursor return rec_type;
    my_cur     cur_type;
    que     varchar2(100);
    tab     varchar2(40);
    BEGIN
    tab := 'dynamic_table_name';
    que := 'select key_name, key_value from ' || tab || ' where key_name like ''01%''';
    open my_cur for que;
    loop
    if my_cur%found then
    dbms_output.put_line('source_name: ' || my_cur.str || ', page_sn: ' || my_cur.num);
    exit;
    end if;
    end loop;
    close my_cur;
    END;
    Running the above trivial example in an anonymous sql block yields the following
    errors as expected:
    ORA-06550: line 10, column 8:
    PLS-00455: cursor 'MY_CUR' cannot be used in dynamic SQL OPEN statement
    ORA-06550: line 10, column 3:
    PL/SQL: Statement ignored
    ORA-06550: line 13, column 54:
    PLS-00487: Invalid reference to variable 'MY_CUR'
    ORA-06550: line 13, column 7:
    PL/SQL: Statement ignored
    Is there a workaround to the situation? Since I do not know the table name at run
    time, I must use Native Dynamic SQL. I have a long and complex record type
    that I wish to return through JDBC using the REFCURSOR Oracle type in order to
    avoid having to register an inordinate number of OUT parameters. Moreover, I
    would like to return potentially one or more results in a ResultSet. Using the
    standard method of registering native SQL types for the IN and OUT bindings
    can only return one result. Hence the reason I would like to return a strong
    cursor type. Also, the type of query I am doing is complex, and needs to be
    executed in a PL/SQL procedure for performance reasons. Therefore simply
    executing a SELECT query dynamically built up on the the JDBC client won't
    do the trick.
    If anybody has experience with a similar problem and would like to volunteer
    information on their workaround, I would really appreciate it.
    Best Regards,
    J. Metcalf

    We can use strongly-typed REF CURSORs in DNS, but the typing derives from a table e.g.
    TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
    so the problem is your use of "return rec_type" bit.
    Forgive my bluntness but I think you have misunderstood strong and weak typing. You actually want to be using weakly-typed cursors. I mean this:
    Moreover, I would like to return potentially one or more results in a ResultSet. suggests that the structure of your resultset may vary, which is precisely what a weakly-typed ref cursor allows us to do. Then we can use the JDBC metadata methods to interrogate the structure of the resultset, innit.
    so try this:
    DECLARE
    type cur_type is ref cursor;
    my_cur cur_type;
    que varchar2(100);
    tab varchar2(40);
    BEGIN
    tab := 'dynamic_table_name';
    que := 'select key_name, key_value from ' || tab || ' where key_name like ''01%''';
    open my_cur for que;
    loop
    if my_cur%found then
    dbms_output.put_line('source_name: ' || my_cur.str || ', page_sn: ' || my_cur.num);
    exit;
    end if;
    end loop;
    close my_cur;
    END;
    ras malai, APC
    Cheers, APC

Maybe you are looking for

  • Steadyshot stabilization for video doesnt work since Lollipop update. HELP!

    Where should I send information about SERIOUS issue of new Lollipop on XPERIA Z3? Since last update from Kitkat the SteadyShot stabilization for video doesnt work (intelligent mode works standard). Previously great videos are now shaky and simply ugl

  • Oracle 10 Express Edition, SID, DBNAME

    Hi i'm from Russia and my english is very bad! Please, help! I'm use Oracle 10 Express Edition and i have a problem: My soft use speciefied database name, how i can (and may be then) rename SID and DBNAME? I .. change instance with "oradim" ,and chan

  • Activation of split valuation

    Gentlemen I would like to activate split valuation for many of MROs.  This is required to implement refurbished process in plant maintenance.  We have stock of many of the materials and open PO and PRs as well. Under this condition is there any way t

  • Can Captivate pass variables to Flash?

    I have a Captivate 4 quiz embedded in a .FLA (AS2).  Can this quiz pass user-defined and/or system variables to the .FLA?  If so, can someone give me an example code of how this would work?  Let's say I have a user-defined variable in Captivate, varT

  • How can I use FRF function after i have collected the raw data?

    I have collected a set of raw data from a vibrational test. I didn't save the FRF results. I was wondering if i can do a FRF post data analysis. Maby by using a modified verison of the FRF (SVXMPL_Baseband FRF (Simulated).vi found in the NI example f