Data Display -- SQL Query?

Hi
This might be simple but, I have no idea.. how to achieve this via a simple SQL Query..
Data in a column :
1
5
6
15
25
30
35
Should do a SELECT showing like this..
1 5
6 15
25 30
35 NULL
Thanks!

create table t1
(numcol     number);
insert into t1 values(1);
insert into t1 values(5);
insert into t1 values(6);
insert into t1 values(15);
insert into t1 values(25);
insert into t1 values(30);
insert into t1 values(35);
commit;
select odds.numcol, evens.numcol
from
   select numcol
         ,row_number() over (order by numcol) rn
   from
      select numcol
            ,row_number() over (order by numcol) rn
      from   t1
   where mod(rn,2) <> 0
)  odds
   select numcol
         ,row_number() over (order by numcol) rn
   from
      select numcol
            ,row_number() over (order by numcol) rn
      from   t1
   where mod(rn,2) = 0
)  evens
where odds.rn = evens.rn (+);
              NUMCOL               NUMCOL
                   1                    5
                   6                   15
                  25                   30
                  35

Similar Messages

  • Can we use session variables in BI publisher's Data Model SQL Query?

    Hi Experts,
    We need to implement Data level security in BI Publisher 11g.
    In OBIEE we do so by using session variables, so just wanted to ask if we can use the same session variables in BI Publisher as well
    ie can we include the where clause in the Data Models SQL Query like
    Where ORG_ID = @{biServer.variables['NQ_SESSION.INV_ORG']}
    Let me know your views on this.
    PS: We are implementing EBS r12 security in BI Publisher.
    Thanks

    Read this -> OBIEE 11g: Error: "[nQSError: 23006] The session variable, NQ_SESSION.LAN_INT, has no value definition." when Creating a SQL Query using the session variable NQ_SESSION.LAN_INT in BI Publisher [ID 1511676.1]
    Follow the ER - BUG:13607750 - NEED TO BE ABLE TO SET A SESSION VARIABLE IN OBIEE AND USE IT IN BI PUBLISHER
    HTH,
    SVS

  • How to aggregate data in SQL Query

    Hi,
    I have Table1 field1 and field2. Combination of these fields form the key of this table.
    Next I have Table2 with field3 and field4. field1 is the unique key for this table.
    My query is:
    select T2.field4||','||T1.field2 from T1 inner join T2 on T1.field1 = T2.field3;
    In the result I want to aggregate the data by T2.field4
    How do I that? Please help
    Thanks in advance,
    Raja

    How to aggregate data in SQL Query By using aggregate functions and group by:
    SQL> select object_type, count(*), sum(decode(status,'VALID',0,1)) inv_obs
      2  from all_objects
      3  group by object_type;
    OBJECT_TYPE                     COUNT(*)              INV_OBS
    CONSUMER GROUP                         2                    0
    INDEX PARTITION                      970                    0
    TABLE SUBPARTITION                    14                    0
    SEQUENCE                             226                    0
    SCHEDULE                               1                    0
    TABLE PARTITION                      349                    0
    PROCEDURE                             21                    0
    OPERATOR                              57                    0
    WINDOW                                 2                    0
    PACKAGE                              313                    0
    PACKAGE BODY                          13                    0
    LIBRARY                               12                    0
    PROGRAM                                9                    0
    INDEX SUBPARTITION                   406                    0
    LOB                                    1                    0
    JAVA RESOURCE                        771                    0
    XML SCHEMA                            24                    0
    JOB CLASS                              1                    0
    TRIGGER                                1                    0
    TABLE                               2880                    0
    INDEX                               4102                    0
    SYNONYM                            20755                  140
    VIEW                                3807                   72
    FUNCTION                             226                    0
    WINDOW GROUP                           1                    0
    JAVA CLASS                         16393                    0
    INDEXTYPE                             10                    0
    CLUSTER                               10                    0
    TYPE                                1246                    0
    EVALUATION CONTEXT                     1                    0

  • Large number of attributes reduces data display in Query (PLS HELP).

    Dear Guru's
    We have newly upgraded our system to 7.0, Currently i have a Query based on master data info object(0 equipment) which contain several attributes, due to huge number of attributes, i cannot see data for few  attributes( Ex:-0service descrip), but data exists for these atrrib, when i check in RSA1. my client want to use heavy number of 0Euipment numbers(nearly 10000) in selection screen. thats the reason for data not to be seen.
    WE are under SP 16 also(Note 562162 - Additional selection of attribute reduces query result set is allready exists), and did not found any proper note.
    So guru's can any one please tell me how i can get the data in Query for these attribute by keeping the same selection option for Equipment numbers (10000).
    Dude's give me some good suggestion please...client is waiting from 1 week
    Thanks in adv
    Dev
    Edited by: Srinivas dev on Jun 10, 2008 11:52 AM

    Dear Yogesh,
    Thanks a lot dude...
    I assigned points for your kindly help....
    Got any idea about by initial post   Large number of attributes reduces data display in Query
    Thanks and Regards
    Dev

  • Need help in UPDATE data in SQL Query

    Hi all,
    I am trying to update data in the sql table as per below screenshot but couldn't able to do it. Can anyone help to update the data as I mention in screenshot.Appreciate you help.Thanks.
    Yellow highlighted columns are source
    Green highlighted columns are target
    Colored data should be update as per source data in sql table.Data is not static as it might have more rows to update and query should be bit dynamic.
    Maruthi...

    You have already asked this question once. You did not get any good answers, because you the information you gave was insufficient. And I'm afraid that the information is still in sufficient.
    Or more exactly, from the example you have given, the answer is: can't be done. And the reason it can't be done, is as I explained in response to you first thread: there is no information in the data to from which we can deduce that Clorox Company
    should be under "Week 1-1,K.B,F". The fact that rows are listed in a certain order in the screenshoot is of no importance, because a table is an unordered object.
    But you said in another post that you have a timestamp column. Maybe that column is usable - maybe it is not. But at least it is a key that you have more columns that the ones you show.
    The best way to get help with this type of problems is to post:
    1) CREATE TABLE statement for your table(s).
    2) INSERT statements with sample data.
    3) The desired result given the sample.
    4) A short description of the actual buisness problem you are trying to solve.
    5) Which version of SQL Server you are using.
    This makes it easy to copy and paste into a query window to develop a tested solution. Screenshots with an insufficient amount of data is not going to help you very much.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Help needed in Exporting tables data through SQL query

    Hi All,
    I need to write a shell script(ksh) to take some of the tables data backup.
    The tables list is not static, and those are selecting through dynamic sql
    query.
    Can any body tell help me how to write the export command to export tables
    which are selected dynamically through SQL query.
    I tried like this
    exp ------ tables = query \" select empno from emp where ename\= \'SSS\' \"
    but its throws the following error
    EXP-00035: QUERY parameter valid only for table mode exports
    Thanks in advance,

    Hi,
    You can dynamically generate parameter file for export utility using shell script. This export parameter file can contain any table list you want every time. Then simply run the command
    $ exp parfile=myfile.txt

  • Date in sql query problem

    Hi,
    I have a search form with 1 field (date picker) - the user chooses a date and a report based on a sql query is shown.
    I want the report to be based on only the month and year, and not the particular day.
    If there is a date picker (or something similar) for only month and/or year, then I can change my form, but I don't see this option.
    So, I'm trying to write my query to ignore the Day portion in the search form and just do a search based on the month and year, but i'm having trouble with this.
    This is my query...
    select d.dept, count(e.emp_id) "No. of Employees"
    from dept d, employees e
    where e.date_created = trunc(:P13_DATE, 'MONTH YYYY')
    and d.dept_id = e.dept_id
    group by dept
    order by dept
    How do I write the where clause so that the search is done only on month and year?
    Or otherwise, how can I change the search form to exclude the day from the date?
    Thanks.

    Hi,
    Oh, the invalid number is the result of :P13_DATE being a string value. all item values are actually strings (or varchar2 if you like) when you referencing them with ':Px_ITEM' format. With the pl/sql function there are 2 possible ways to reference item, namely the function: V('Px_ITEM') and NV('Px_ITEM'). Although in SQL varchar2 => number conversion can be dealed with by the SQL engine.
    Unfortunally there is no pl/sql method for getting a DATE of an date-picker item (based on its format mask etc.). Patrick Wolf has added this function in his ApExLib framework, function DV. I find this a nice extension.

  • Data Model - SQL Query

    Hi everyone,
    Hopefully someone can point me in the right direction.
    I have the following SQL in the Data Model type SQL Query.
    select * from ap_invoices
    This select statement is not return any rows from the view but does so from sqlplus.
    I am using BIP 10.1.3.4.1 and have setup the EBS Security model.
    What am i doing wrong, is there some setup i am missing?
    Do i need to use a different security model for BIP?
    please help
    thankyou.

    Hi
    AP_INVOICES is a view as you know, its based on the ORG_ID being set when you select from it. Im thinking that when you just use select * from AP_INVOICES in BIP. Its unaware of your org id and its not setting it for you when you run a query, so its not returning data. Two options:
    1. Use a data template and in the pre-fetch trigger set the org context. Just like you might have in an Oracle Report. Data templates are very powerful and provide everything OReports does in EBS incl triggers and flex extensions
    2. Use the AP_INVOICES_ALL table and set the org id in the query where clause.
    Both approaches need for you to know the org id you want to set. The security integration you have will not have this ie it does not pass it when the user logs on. I guess as you have a report folder for every responsibility you could hard code the org id into the reports in a given folder. Or you could add it as a parameter to the report for the user to fill out.
    The level integration just does not quite go far enough at the moment to handle the org and therefore the org views.
    hope this is clear
    Regards
    tim

  • Display SQL query in error text

    Using CFMX 6.1.
    Is it possible to get our error handler page to display the
    SQL query that fails and causes an error?
    If tried #error.sql# but it doesn't exist after a db
    exception. If I put a cftry around a particular query and then use
    cfcatch.sql within a cfcatch tag pair, it works fine. But given our
    error handler page is for the entire site, I can't use cfcatch, at
    least not the way the site is currently architected. I was hoping
    error.sql would work since my quick ref quide states that "Any
    cfcatch variable that applies to exception type can be accessed
    within the Error scope. But then it doesn't list Error.SQL or
    CFCATCH.SQL for that matter in any documentation I've seen, yet the
    later works in cfcatch tags.
    Any help would be appreciated.

    You don't have to place a CFTRY/CFCATCH around each query. I
    don't know how many pages you have in your application, but you
    could do something like the following:
    1. Replace <body> with <body><CFTRY>
    2. Replace </body> with the following
    <CFCATCH TYPE="database">
    <CFMODULE TEMPLATE="customErrorPage.cfm"
    sqlStatement="#CFCATCH.Sql# " message="#CFCATCH.message#">
    </CFCATCH>
    </CFTRY>
    </body>
    You can use a global search-and-replace utility, such as
    SR32, to make this task painless. Click
    here to go to the SR32
    site.

  • Failing to import data using SQL query

    I am trying to import data from a sql query to analysis service in SSDT. i went to model > import from data source >Microsoft SQL Server and i chose from query. I typed my query which works fin in SSMS and when i press import if gives me a error. what
    is going on please help here is the error
    DirectQuery error: All tables used when querying in DirectQuery Mode must be from a single relational Data Source.
    here is my query:
    USE AdventureWorks2012;
    SELECT SalesPersonID, [29484] Brian, [29485] Peter, [29486] Frank, [29518] Sarah, [29519] Janet, [29520] Alice, [29608] Martin, [29609] Patrick, [29610] Wasu, [29780] Samanyika, [29781] Vladmire
    FROM
    SELECT SalesOrderID, SalesPersonID, CustomerID 
    FROM Sales.SalesOrderHeader
    WHERE SalesPersonID IS NOT NULL
    As P PIVOT
    COUNT (SalesOrderID) FOR CustomerID IN ([29484], [29485], [29486], [29518],  [29519], [29520], [29608], [29609], [29610], [29780], [29781])
    AS PVT
    ORDER BY SalesPersonID ASC;

    Hi,
    When importing data from relational data source, the steps are:
    In SQL Server Data Tools (SSDT), click the Model menu, and then click Import
    from Data Source.
    On the Connect to a Data Source page, select the type of database to connect to, and then click Next.
    Follow the steps in the Table Import Wizard. On subsequent pages, you will be able to select specific tables and views or apply filters by using the Select
    Tables and Views page or by creating a SQL query on Specify a SQL Query page.
    As we can see on the steps, we need to select one database, so we needn't to write "USE AdventureWorks2012" on the query.
    Reference:Import from a Relational Data Source
    Regards,
    Charlie Liao
    TechNet Community Support

  • RSRT Performance Display SQL - Query has variables

    I have a query with mandatory variables on Year and Period, which are built into my RKF's.  I am trying to run the query via RSRT to see the SQL, but I keep getting error, variables must have values.....I tried creating variant in RSRT, but it goes to some odd screen.

    I do not get a prompt screen.  I go to RSRT,  Enter Query Name, next I Select Performance Info tab, then hit "Display SQL" button.  I get a message:  Specify a value for variable Posting Period (Single Value Entry, Mandatory)
    I never get a prompt.  I am on BI 7.

  • Display Sql query result

    i have a c++ form that accepts data and saves it on a table in a database via a button click, this is the code for the eventprivate: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    String^ constring=L"datasource=localhost;port=3306;username=root;password=lampard";
    MySqlConnection^ conDatabase=gcnew MySqlConnection(constring);
    MySqlCommand^ cmdDatabase=gcnew MySqlCommand("insert into test.Data(Full_Name,Matric_No) values('"+this->textBox1->Text+"','"+this->textBox10->Text+"') ;" ,conDatabase);
    MySqlDataReader^ myReader;
    try{
    conDatabase->Open();
    myReader=cmdDatabase->ExecuteReader();
    MessageBox::Show("Saved");
    while(myReader->Read()){
    }catch(Exception^ex){
    MessageBox::Show(ex->Message);
    NOW i want to send a query to give out this information in a new form or in a form exactly like the one used to enter the data, this is how far i have come
    private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    this->Hide();
    MyForm ^ Form = gcnew MyForm(this);
    Form->ShowDialog();
    String^ constring=L"datasource=localhost;port=3306;username=root;password=lampard";
    MySqlConnection^ conDatabase=gcnew MySqlConnection(constring);
    MySqlCommand^ cmdDatabase=gcnew MySqlCommand("Select * from test.Data where Matric_No='"+textBox1->Text +"';",conDatabase);
    MySqlDataReader^ myReader;
    try{
    conDatabase->Open();
    myReader=cmdDatabase->ExecuteReader();
    while(myReader->Read()){
    textBox1->Text ;
    }catch(Exception^ex){
    MessageBox::Show(ex->Message);
    NOte: MyForm is the title of the form used to enter in the data sent to the database please how do i get the program to display the data meeting the query criteria into a form?

    i made textBox1 a public memeber of MyForm class and i changed  
    Form->ShowDialog(); to Form->Show() and i entered the code you advised me to and it displayed the result.i am very grateful, thank you

  • How to create a Matrix table using this data in SQL Query Analyzer

    Hello all,
    I have a problem while I am trying to represent my Sql Table namely table1 in Matrix form
    my table Format is
    city1 city2 Distance--------------------------------------------------------
    Mumbai Delhi 100
    Delhi Banaras 50
    Mumbai Rajasthan 70
    Banaras haryana 40
    Mumbai Mumbai 0
    784 entries
    there are 784 cities each having link to other
    Now i want my output as
    Mumbai Delhi Banaras haryana
    Mumbai 0 100 -- --
    Delhi 100 0 50 --
    Banaras
    haryana
    respective distance from one city to other should be shown
    final Matrix would be 784*784
    I am using SQL Query Analyser for this
    Please help me in this regard

    I'm pretty much certain that you don't want to do this in pure SQL. So that means that you want to do it with a reporting tool. I'm not familiar with SQL Query Analyzer, but if it is in fact a reporting tool you'll want to consult its documentation looking for the terms "pivot" or perhaps "cross tab."

  • How to display contineous 10 dates from today date using SQL query

    Hi All
    I need a requirement of displaying 10 dates and numbers contineously, I have written a query for getting 10 numbers like this
    select rownum from dual where rownum < 10 connect by rownum = level;
    But i am not able to get the dates, Can any one help me ?

    Hi Satyaki,
    No issues on my 9.2.0.8 client.
    SQL*Plus: Release 9.2.0.8.0 - Production on Sat May 3 09:49:17 2008
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    SQL> conn test/test@db10g
    Connected.
    SQL> select rownum, trunc(sysdate) + rownum from dual where rownum <= 10 connect by rownum = level;
        ROWNUM TRUNC(SYS
             1 04-MAY-08
             2 05-MAY-08
             3 06-MAY-08
             4 07-MAY-08
             5 08-MAY-08
             6 09-MAY-08
             7 10-MAY-08
             8 11-MAY-08
             9 12-MAY-08
            10 13-MAY-08
    10 rows selected.
    SQL> Regards

  • Combining data from SQL query

    Hoping there is a SQL guru out there that can help me with this
    I have two tables that I want to pull data from and display a report, based on a particular date range, for this example let's say 08/01/2011 to 08/31/2011
    In one table there would be an affiliate ID - AFF_UID and also the date and a counter for that date, IMP_COUNTER , now there may only be a few records not every day might be covered, say
    TABLE IMP
    date,aff_uid,imp_counter
    08/01/2011,999,2000
    08/02/2011,999,2050
    08/20/2011,999,2030
    etc
    I then have another date, similar set up only there are multiple records in here for a single day, again not all days covered, I would need to total up each row for each day to get a count. So it might be:
    TABLE LEAD
    date,aff_uid
    08/01/2011,999
    08/01/2011,999
    08/01/2011,999
    08/01/2011,999
    08/12/2011,999
    So we have different dates covered, sometimes the same date, I need the counter from the first table, and from the second table I need to add them up for a total, and then display any date that has a value and put both counter and lead count together
    Result from above
    date,imp total,lead total
    08/01/2011,2000,4
    08/02/2011,2050,0
    08/12,2011,0,1
    08/20/2011,2030,0
    I am sure there must be a SQL command that can gel all of this together with some grouping? Last thing I need is a ton of SQL statements in a loop!
    My alternative is to add a counter to the IMP table for each lead, so every time I update the lead table with a record, I will also update the counter, but that's unncessary storage of data I already have an an extra update statement that I might be able to do without, but maybe it would make generating reports faster, just pulling to counters with no 'addition' required.
    Appreciate any feedback
    Thanks
    Mark

    Well I thought that I had this one up and running, but once it went into production I found that it didn't give the desired results.
    I have an account that has 3 'tracking'/aff accounts, so what it's doing is giving out 3 lines for each date rather than join them together into one. The values are also incorrect, I'm still trying to figure out just where it's even getting those numbers, I manually added up the numbers in the dbase and it didn't match
    Here's the command
    <CFQUERY name="GetStats" DATASOURCE="#datasource#">
    SELECT
    COALESCE(IMP.imp_date, LEAD.lead_date) AS report_date
    , COALESCE(IMP.imp_counter,0) AS imp_counter
    , COALESCE(LEAD.lead_count,0) AS lead_count
    , COALESCE(LEAD.lead_aff_payment,0) AS lead_aff_payment
    FROM
    SELECT
    imp_date
    , imp_counter
    FROM impressions
    WHERE imp_date BETWEEN #createODBCdate(form_from)# AND #createODBCdate(form_to)#
    <CFIF #val(ListGetAt(form_aff_UID,1))# IS "3">
    AND imp_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_master_uid = #session.aff_uid#)
    <CFELSEIF #val(ListGetAt(form_aff_UID,1))# IS "2">
    AND imp_aff_uid  = #val(ListGetAt(form_aff_UID,2))#
    <CFELSE>
    AND imp_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_sub_uid = #val(ListGetAt(form_aff_uid,2))# AND aff_master_uid = #session.aff_uid#)
    </CFIF>
    ) AS IMP
    FULL OUTER JOIN
    SELECT
    lead_date, COUNT(*) AS lead_count, SUM(lead_aff_payment) AS lead_aff_payment
    FROM leads
    WHERE lead_date BETWEEN #createODBCdate(form_from)# AND #createODBCdate(form_to)#
    AND lead_data_status = 1
    <CFIF #val(ListGetAt(form_aff_UID,1))# IS "3">
    AND lead_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_master_uid = #session.aff_uid#)
    <CFELSEIF #ListGetAt(form_aff_UID,1)# IS "2">
    AND lead_aff_uid = #val(ListGetAt(form_aff_uid,2))#
    <CFELSE>
    AND lead_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_sub_uid = #val(ListGetAt(form_aff_uid,2))# AND aff_master_uid = #session.aff_uid#)
    </CFIF>
    GROUP BY lead_date
    ) AS LEAD
    ON ( IMP.imp_date = LEAD.lead_date )
    ORDER BY report_date;
    </CFQUERY>
    and here are the results
    TRAFFIC REPORT: 01/01/2012 - 01/21/2012
    All Accounts
    Date
    Offers
    Served
    Total
    Leads
    Revenue
      01/19/2012
    249
    1
    $0.38       
      01/19/2012
    11
    1
    $0.38       
      01/19/2012
    30
    1
    $0.38       
      01/20/2012
    1,006
    7
    $2.66       
      01/20/2012
    40
    7
    $2.66       
      01/20/2012
    1,090
    7
    $2.66       
      01/21/2012
    582
    6
    $2.28       
      01/21/2012
    33
    6
    $2.28       
      01/21/2012
    515
    6
    $2.28       
    Total
    3,556
    42
    Sub-Total
    $15.96       
    Referral Revenue
    $0.00       
    Total
    $15.96  
    $15.96 is NOT correct, I need to find out whats going on there, but the other issue is look how it's duplicating the dates, it's one line for each account by the look of it
    Can anybody help! This SQL command already got a little beyond me
    Thanks
    Mark

Maybe you are looking for

  • Iphone G3 screen goes black after ending every call.

    My iphone screen goes black after ending a call. Shouldn't I have to hit the "end call" button? I'm having to re-boot the phone after every call I make. Anyone else have similar issues?

  • Unwanted "Search using Search" keeps reappearing in search box

    I have the search box set to Amazon and Ebay only. Suddenly "Search" which brings up results in Bing has infected itself in there and nothing gets rid of it, not removing it, Spybot, Malwarebytes. It always brings itself up to the top, only to be rem

  • IPhoto '08 - Saturation Slider Messed Up

    The Saturation adjustment feature in iPhoto '08 seems to be seriously messed up. It's ok if you go left of the default value, removing saturation. But if you increase the saturation to the right, beyond the default value, it darkens the photo! And it

  • What is the best camcorder for a mac?

    Hello everyone, I am a total newbie in terms of imovie and video recording. I am also just got this macbook recently and, oh my, I wish I would have gotten a macbook many years sooner So my question is: what camcorder is easy to use with a macbook fr

  • I can't open my iphoto folder, it's blocked-:(

    DID ANYBODY EVER HAD THIS PROBLEM?