Single row from this query without create a group by

Can I have a single row from this query without create a group by on tipo (TIPO can have only 2 value (A,D)
SELECT
CASE TIPO
WHEN 'D' THEN SUM(IMPORTO) ELSE 0 END DIMPORTO,
CASE TIPO
WHEN 'A' THEN SUM(IMPORTO) ELSE 0 END AIMPORTO
FROM MGIORNALE
WHERE K_CONTO = '100001' --CONTO
AND DECODE(T_MOVIM,'MRAP',TO_DATE('31/12/'||to_char(a_competenza),'DD/MM/YYYY'),DATA_RG)
-- BETWEEN DATAA AND DATAB
BETWEEN '01/01/2006' AND '31/12/2006'
--GROUP BY TIPO
--AND TIPO = COL_conto
Thanks in advance

Is like this?
sum (CASE TIPO
WHEN 'D' THEN IMPORTO ELSE 0 END) DIMPORTO,

Similar Messages

  • How to call a method from a class without creating an instance fromthisclas

    I want to create a class with methods but I want to call methods from this class without creating an instance from this class. Is this possible?
    Is there in Java something like class methods and object methods????

    keyword 'static' my friend.
    public class foo {
    public static void bar {
    System.out.println ("hello");
    foo.bar()

  • UPDATE single ROW from DATAGRID without refreshing the entire ItemsSource

    Hello there,
       I have a simple datagrid that has an ItemsSource of ObjectQuery<DbDataRecord>.
       Let's say I want to refresh a single row from the datagrid, (Because a specific item i know has been changed) without refreshing the entire ItemsSource because the source query is quite big.
    Any ideas?
    Thanks.
    -- Jorge_M_P

    Whilst you could raise property changed on every field in an item, that would of course mean implementing inotifypropertychanged on a wrapper object, then iterating all of those properties.
    An observablecollection implements the INotifyCollectionChanged interface.
    Amongst the possibilities for changes which that notifies are this one:
    https://msdn.microsoft.com/en-us/library/ms653207(v=vs.110).aspx
    Which notifies of a single item change.
    I usually wrap my entity framework objects.
    Sometimes I wrap all the properties so I can do change tracking in the viewmodel.
    This is a technique similar to the one I use in this sample:
    https://gallery.technet.microsoft.com/WPF-Highlight-Changed-a77976d4
    Which wraps plain classes - but the principle is the same.
    And
    I wrap the object and expose that, as I do in this:
    http://social.technet.microsoft.com/wiki/contents/articles/28209.wpf-entity-framework-mvvm-walk-through-1.aspx
    Note that because I wrap the same objects returned from EF, there is very little overhead in using an observable collection there.
    Hope that helps.
    Recent Technet articles:
    Property List Editing ;  
    Dynamic XAML

  • Updating, Adding, or Deleting rows from a query

    So, I've got this page that originally was made of four
    different forms. It worked great. But, then the client asked that I
    "idiot proof" the page.
    Originally, I had a form that enclosed a one-line table (with
    Add & Clear buttons on the end) that took seven fields and
    "added" a new record to the "tbljob" table.
    That was followed with another form that created a table from
    the results of a cfquery and listed all the rows from tbljob (with
    Update/Delete buttons on the end of each row).
    This worked fine when it was two separate forms. Now, I'm
    trying to use only one "form" while displaying the two tables. The
    buttons are now done with Javascript (so there are dialog boxes).
    The problem is that I am getting a CF error message because the
    insert, update, and delete commands are trying to pass the contents
    of the fields as comma-delimited lists rather than the single data
    item that is actually in each field. I am passing a hidden field
    with each row that contains the "job_id".
    I know the problem is that I'm not identifying each row as
    being unique. I guess it's like I'm passing an "array" of data
    rather than just a "row".
    Basically, I just want to be able to display a blank row for
    adding records followed by multiple rows from a query. The blank
    row needs to have "Add" and "Cancel" buttons at the end and the
    multi-row part has to have "Update" and "Delete" buttons on the end
    of each row and manage the appropriate records.
    It's got me stumped. TIA.

    What you can do is try using <cfloop> to insert, update
    and delete your information.
    For instance deleting the information try this.
    <!---- Delete Jobs---->
    <cfloop index="JobIDs" list="#Job_ID#" delimiters=",">
    <cfquery name="delteall" datasource="dbsource">
    DELETE
    FROM table
    Where job_Id = #JobIDs#
    </cfquery>
    </cfloop>
    Do the same for your inserting and updating.
    Because what CF see is job_id = 1,2,3,4,5,6,7,8,9
    SO you are looping over a list = #job_id# and delimiter is "
    , " and we are calling the index JobIDs. JobIDs are the values - 1
    2 3 4 5 6 ....
    I hope this helps. As for the displaying of the images, use
    if then statements:
    <cfif isdefined("edittable") and edittable eq '"y">
    Then display the query and outputs for the editing options
    <cfelseif isdefined("deletetable") and addtable eq "y">
    The dispaly the query and outputs for adding options
    <cfelse>
    Then display the query for outputing the delete options
    </cfif>
    So your link will have soemthing of this sort <a
    href="samepage.cfm?deletetable=y">Add Table</a>
    Hope this helps,
    Sevor Klu

  • Grouping rows from a query

    Hi everyone!
    I want to know if it's posible to group the rows from a query into a unique row. Example:
    SELECT Field_1 FROM Table_1
    Returns the following fileds:
    Field_1
    A
    B
    C
    D
    I would want to modify my query so that the result obtained would be a single row containing all the others. In the previous example the result would be "ABCD".
    Thanks in advance. Best regards,

    -- For anyone who wants to test this,
    -- just copy this entire post as is,
    -- save it to a .sql file, then start that file.
    -- Before doing this,
    -- make sure that you don't already have
    -- a table named table_1 that would be dropped
    -- or a .sql file named query.sql that would be overwritten.
    -- If you do, then change the names below to avoid any conflicts.
    -- In order to understand what the code is doing,
    -- please read all of the comments included in this file,
    -- as not everything is displayed when you run it.
    -- I have gone into great detail with this
    -- because I have posted similar things before
    -- and a lot of people have total missed the fact
    -- that it is not a static query,
    -- that the results are dependent upon the number of rows,
    -- and that it works for any number of rows,
    -- even when the number of rows is unknonwn.
    -- test data:
    DROP TABLE table_1
    CREATE TABLE table_1
      (field_1 VARCHAR2 (1))
    INSERT INTO table_1 (field_1)
    VALUES ('A')
    INSERT INTO table_1 (field_1)
    VALUES ('B')
    INSERT INTO table_1 (field_1)
    VALUES ('C')
    INSERT INTO table_1 (field_1)
    VALUES ('D')
    COMMIT
    SELECT * FROM table_1
    -- Running the code below will create and start
    -- a file named query.sql which will contain the query below,
    -- which will produce the results below that:
    -- query that will be created:
    -- SELECT MAX(DECODE(ROWNUM,1,field_1,NULL))                                      
    -- ||MAX(DECODE(ROWNUM,2,field_1,NULL))                                           
    -- ||MAX(DECODE(ROWNUM,3,field_1,NULL))                                           
    -- ||MAX(DECODE(ROWNUM,4,field_1,NULL))                                           
    -- FROM table_1 GROUP BY NULL;                                                    
    -- results that will be produced:
    -- ABCD
    -- Notice that in this example,
    -- there are only four values concatenated
    -- because there are only four rows in the table. 
    -- If there were more rows, it would concatenate more values. 
    -- The number of concatenated values
    -- is dependent upon the number of rows.
    -- The following dynamic sql uses a single query,
    -- which produces and executes a single query,
    -- whose number of concatenated values is dependent
    -- upon the number of rows in the table.
    -- Because the echo is set off in the first line,
    -- you won't see this code when you run it,
    -- just the query that it creates.
    SET     ECHO OFF FEEDBACK OFF HEADING OFF PAGESIZE 0 VERIFY OFF
    SPOOL   query.sql
    -- This is the start of the single query:
    SELECT  text
    FROM    (SELECT 1                                             AS orderby,
                    'SELECT MAX(DECODE(ROWNUM,1,field_1,NULL))'   AS text
             FROM   DUAL
             UNION
             -- This section is the part that dynamically creates
             -- one additional concatenated value
             -- for each additional row after the first row.
             -- This is just a subquery within the single query.
             SELECT rn                                            AS orderby,
                    '||MAX(DECODE(ROWNUM,'||rn||',field_1,NULL))' AS text
             FROM   (SELECT ROWNUM rn
                     FROM   table_1)
             WHERE  rn > 1
             UNION
             SELECT COUNT (*) + 1                                  AS orderby,
                    'FROM table_1 GROUP BY NULL;'                  AS text
             FROM   table_1)
    ORDER BY orderby;
    -- This is the end of the single query.
    SPOOL    OFF
    START    query
    SET      ECHO ON
    -- If you want to see the file containing
    -- the single query that was created, then just:
    -- SQL> EDIT query.sql

  • Single row from one-to-many

    I am having trouble with a query, I need a single row from a 1-to-many relationship that is prioritized by certain ID's.
    Department Table - dept_id,dept_name
    Employee Table - emp_id, emp_name
    D-E-Lookup Table - dept_id,emp_id
    Employee ID priority are 5,8,9,21,33,78
    I need each department name with the associated employee name.
    There should be only one row per department.
    If that department does not have empID 5, than 8, if not 8 then 9, if not 9 than 21, etc
    Any help would be greatly appreciated.

    How about this:
    WITH departments AS
        ( SELECT ROWNUM AS deptno, COLUMN_VALUE AS dname
          FROM   TABLE(sys.dbms_debug_vc2coll('Sales','IT','Research')) )
       , employees AS
        ( SELECT ROWNUM AS empno, COLUMN_VALUE AS ename
          FROM   TABLE(sys.dbms_debug_vc2coll('Bennett','Parkman','Nakamura')) )
       , department_assignments AS
         ( SELECT 1 AS deptno, 1 AS empno, 5 AS priority FROM dual UNION ALL
           SELECT 1 AS deptno, 2 AS empno, 8 AS priority FROM dual UNION ALL
           SELECT 1 AS deptno, 3 AS empno, 9 AS priority FROM dual UNION ALL
           SELECT 2 AS deptno, 2 AS empno, 8 AS priority FROM dual UNION ALL
           SELECT 2 AS deptno, 3 AS empno, 9 AS priority FROM dual UNION ALL
           SELECT 3 AS deptno, 1 AS empno, 9 AS priority FROM dual UNION ALL
           SELECT 3 AS deptno, 3 AS empno, 21 AS priority FROM dual )
    SELECT dname, ename, priority
    FROM   ( SELECT d.dname
                  , e.ename
                  , dp.priority
                  , DENSE_RANK() OVER (PARTITION BY d.deptno ORDER BY dp.priority) AS ranking
             FROM   departments d
                    LEFT JOIN department_assignments dp ON dp.deptno = d.deptno
                    LEFT JOIN employees e ON e.empno = dp.empno )
    WHERE ranking = 1;
    DNAME         ENAME             PRIORITY
    Sales         Bennett                  5
    IT            Parkman                  8
    Research      Bennett                  9
    3 rows selectedThe <tt>WITH</tt> clause is just to define test data inline rather than creating tables, in case that's not clear.

  • Retrieve a single row from Oracle function

    Hi!
    I have an Oracle function created as follow:
    CREATE OR REPLACE FUNCTION user_data(userId IN users.user_id%TYPE)
    RETURN users%ROWTYPE AS
    userData users%ROWTYPE;
    BEGIN
    SELECT * INTO userData
    FROM users
    WHERE user_id = userId;
    RETURN userData;
    END user_data;
    This function returns a single row from 'users' table.
    I tried to retrieve that single row by mean of:
    CallableStatement statement = connection
    prepareCall("{ call ? := get_data(?) }");
    statement.*registerOutParameter(1, OracleTypes.OTHER)*;
    statement.setInt(2, 103);
    statement.execute();
    ResultSet rs = (ResultSet) statement.getObject(1);*
    String value = rs.getString(2);
    System.out.println(value);
    But this code doesn't work.
    I tried other OracleTypes, also. (I don't know what OracleType I receive when the Oracle function return a ROWTYPE.)
    Can somebody tell me how to retrieve that single row?
    What is the type of out parameter (registerOutParameter()) when the Oracle function return a ROWTYPE?
    Notes: No cursor can be added. No database change is allowed.
    Thank you in advance.
    [Adrián E. Córdoba]
    Edited by: aecordoba on Mar 18, 2011 3:58 PM

    aecordoba wrote:
    I beg your pardon for my bad English. (It isn't my original language.)
    It's not a language problem. It's that you didn't provide any details about what went wrong.
    That just is my problem:
    I know the retrieved result is not a result set: It's a single row.Doesn't matter if it's a single row. You have a ResultSet object. You have to call ResultSet's next() method to get to the first row, even if it's the only row.
    1- Which is the Oracle type I receive in Java when the Oracle function returns a ROWTYPE?I don't know.
    2- How can I get each column value when I receive a single row in Java?The same way as when there are multiple rows: For each row, call ResultSet.next() to advance to the next row, then call the appropriate ResultSet.getXxx() methods to get each column's value. Again: If you have a ResultSet, you must call next() to get to the first row, even if there is only one row. "First row out of 1 total row" is no different than "first row out of 100 total rows."
    EDIT: Okay, I didn't notice before that you're using a CallableStatement with "out" parameters. I've never used one of those before, so I'm not familiar with the details. I really don't know if casting to a ResultSet is appropriate here. Do you actually have documentation that says you can do that, or are you just guessing and trying to find something that works.
    Edited by: jverd on Mar 18, 2011 11:26 AM

  • Select a single row from a billion row table

    This is a fictitious scenario, how would you write a select statement on a table with a billion rows. It never returns anything,right? Somebody was suggesting a stored procedure.
    As an example : Assuming a Table with columns      Account(int), TransDate(DateTime), TransNum(int) and few other columns. I need a transaction that happened on 03-05-2014 8:15PM. Clustered index on Account. Non- clustered on TransDate.
    I was suggested to create a stored procedure, inside the SP you have 3 parameters: min_date, max_date, avg= min_date+max_date/2. You create a loop and feed the avg value to the max_date or min_date depending on where the row is. This is a suggestion
    that I am not clear my-self but wanted to see if you guys can help me develop this idea.
    Also please suggest how you would do it in your world. You guys could have much better ideas probably much simpler one's. Thanks in advance.
    svk

    I basically just need transaction for one particular datetime. Not any span. One of our senior developers suggested that a simple select statement takes for ever to return a single row from a billion rows and suggested a vague idea as above. 
    Either there is a suitable index on the column, and the SELECT will be fast.
    Or there is no index on the column, and in that case it will take quite some time to find the row. The only reason to loop is that you don't want to take out a table lock, but in that case you would do something like looping one account at a time. Looping
    over different time values will only mean that you will scan the table multiple times.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to rewrite this query without sub query please help me

    Hello All Good Evening,
    Could you please help me with this query, how can i write this query without sub query, or how can write this query another ways
    please help me
    select planno, status1, count(*) Counts from
    select a.ValetNO PlanNo  ,
    case 
         when JoinCode in ('00', '01', '02') then 'Actcess'
         when JoinCode in ('20', '21', '22', '23','38', '39') then
         'Secured' else 'Other' end Status1 ---, COUNT (*)
       from  dbo.ppt a(NOLOCK)  left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO  = b.ValetNO
    --group by a.ValetNO
      a group by planno, status1
    order by 2
    Thank you in Advance
    Milan

    Whats your objective here? Sorry, am not able to understand the reason for this change. 
    Try the below:(Not tested)
    ;With cte
    As
    select a.ValetNO PlanNo ,
    case
    when JoinCode in ('00', '01', '02') then 'Actcess'
    when JoinCode in ('20', '21', '22', '23','38', '39') then
    'Secured' else 'Other' end Status1 ---, COUNT (*)
    from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
    select planno, status1, count(*) Counts from cte
    a group by planno, status1
    order by 2
    Even below:
    select a.ValetNO PlanNo ,
    case
    when JoinCode in ('00', '01', '02') then 'Actcess'
    when JoinCode in ('20', '21', '22', '23','38', '39') then
    'Secured' else 'Other' end Status1 , COUNT (1)
    from dbo.ppt a(NOLOCK) left join dbo.acts b on a.P_ID = b.P_ID and a.ValetNO = b.ValetNO
    Group by a.ValetNO ,
    case
    when JoinCode in ('00', '01', '02') then 'Actcess'
    when JoinCode in ('20', '21', '22', '23','38', '39') then
    'Secured' else 'Other' end

  • When trying to log in with my primary Apple ID and password, I am continuously asked for my pass word without being able to log in. How can I solve this issue, without creating a new Apple ID?

    When trying to log in with my primary Apple ID and password, I am continuously asked for my pass word without being able to log in. How can I solve this issue, without creating a new Apple ID?

    Chewning wrote:
    I saved some of my music to a Cloud I can't access. Now, they show up as "Purchased" in iTunes, and I'm not given the option of re-downloading OR repurchasing them.
    Music purchased from the iTunes store is not stored in your personal iCloud account, and an iCloud account is not required to redownload them.  You should be able to redownload them as explained here: http://support.apple.com/kb/ht2519.  If you are unable to, contact iTunes store support for assistance by going to https://expresslane.apple.com ; click ‘iTunes', and then 'iTunes Store', then 'Purchases, Billing & Redemption'.

  • How to add pdfs n movies from my PC without creating ne library

    How to add pdfs n movies from my PC without creating ne library... Does iTune has ne converter tht can convert movie into format that iphone can play..

    That's easy, while connecting the iPod to the computer on Windows with iTunes 7.3 installed hold down the Shift + Ctrl keys. This will stop the iPod from auto-syncing with iTunes and the iPod will appear in the source list. Wait until you are sure the iPod has mounted, and that it will not auto sync and then you can let the keys go. This may take between 20 to 30 seconds depending on your computer. If your iPod shows up ok in iTunes you can change it to manual from there.
    http://docs.info.apple.com/article.html?path=iTunesWin/7.3/en/keycuts.html
    (it's also in iTunes > Help if you forget)
    Message was edited by: Katrina S.

  • Retrieve a single row from Multirow ResultsetObject

    I would like to know how can i retrieve a single row from a multi row result object. I have a result object which retrieved multiple rows and i would like to retrieve only the top row or a specific row. Can any one of you suggest how this can be done. Thank you for all the help in advance.

    call next() on your result set, this goes to the first row and you can retrieve the data with getString(), getInt(), etc.

  • Deleting single row from Special Price for Business Partners

    Hi Experts,
    How would I go about about deleting a single row from Special Prices for Business Partners across all BPs when for most of my BPs this is the only special price they have.  I have tried using Copy Discounts function but once you are down to 0 rows the record has effectively gone from the table so there is nothing to copy. 
    Hopefully I won't have to go thorugh 5000 records and delete each one idividually.
    Thanks
    Jon

    Hi Jon,
    You may try a tool called B1TCH:
    /people/community.user/blog/2007/08/19/get-your-kicks-with-di-commander
    Thanks,
    Gordon

  • Importing single row from an exported dump of many tables

    Hi all,
    I have a requirement to import a single row from a exported dump which has collection of tables in it.
    i have used export of a single row and import of single row(from single row export dump), now i need to import a single row from a dump containing collection of tables...
    kindly help me out with this.

    971424 wrote:
    Hi all,
    I have a requirement to import a single row from a exported dump which has collection of tables in it.
    i have used export of a single row and import of single row(from single row export dump), now i need to import a single row from a dump containing collection of tables...
    kindly help me out with this.post command line that produced the dump file.
    How do I ask a question on the forums?
    SQL and PL/SQL FAQ

  • Delete single row from DBTAB

    Hi Experts,
    I want to delete a single row from DBTAB ( KLAH )
    WHERE KLAHKLART = '2'  and  KLAHCLINT = '241'.
    Please advice
    Karthik

    Hi ,
    Try this code  To delete single record from DB table- -
    DATA : t_klah LIKE TABLE OF klah,
           fs_klah LIKE klah.
    SELECT * FROM klah INTO TABLE t_klah
                   WHERE klart = '2' AND
                         clint = '241'.
    LOOP AT t_klah INTO fs_klah.
      DELETE klah FROM fs_klah .
      EXIT.
    ENDLOOP.
    Regards
    Pinaki

Maybe you are looking for

  • How to create a new report using MS Word add-ins?

    Hi, I am a newbie. I am using BI Publisher 10.1.3.4 and l want to create a simple report using BI Publisher from MS Word add-ins. I don't have a default template. What are the steps to create a new report from scratch. I want to create a simple repor

  • J_security_check stalls

    I have configured my struts web app to use JAZN authentication, in web.xml, shown partly below.. When i direct my browser I get directed to error.jsp. Earlier I had configured the OC4J to use JAZN using JAZN admin tool, I have configured orion-applic

  • ITunes not posting my reviews.

    Greeeting to all! My first post and it's long so please bear with me. I have downloaded over 200 applications as well as hundreds of songs from iTunes. I recently noticed that alot of my reviews for applications are not being posted. They all abide b

  • SERVERS

    Hi all, I am new in ABAP what is meant by 1. Development Server 2. Quality server. 3. Production server. what is the differents between them? How we findout that which server that we are woking  ? How to transport the objects from one server to anoth

  • PanelGrid Border Formatting

    Hi guys, Well, I wanted to do some colspan's with h:panelGrid, but everything I read so far says that it isn't possible. So I'm forced into nesting panelGrids inside each other. That's fine. However, the borders are "doubling" ontop of each other. I