EXCEPT based on a specific column value...

I have two tables of user data. There is a unique identifier for a each user. The data in Table A has priority. I want a query that selects all of the users in table A and the users in table B that don't have a row in Table A. While the unique id will identify
them, the rest of the data may not be the same, so I can't use an EXCEPT. Unless there is a way to say EXCEPT based on just the unique id.  There are several million rows.  What's the most efficient way to accomplish this?
Would I just add a where clause with a NOT IN subquery listing the unique ids?
Thanks.
J
http://digitalcamel.blogspot.com/

>> I have two tables of user data. <<
As opposed to your “non-user data”; think what you are saying and where it the DDL is. Now we start guessing and trying to read your mind. 
>> There is a unique identifier for a each user. <<
Yes, this is the definition of an entity. But how did you model it? Where is the DDL? 
>> The data in Table A has priority. <<
what does that Crap mean? In RDBMS, all sets are equal without any concept of a “priority”, so you are absurd. Also. Why do you think that “A”, “B”, etc are good names for a table? They are the names of the physical disk or tape drive in 1970's hardware. 
>> I want a query that selects all of the users in table A and the users in table B that don't have a row in Table A. <<
If you were competent, the DDL you weer too rude to post, would have a single Users table with a user_type of {'a', 'b'} as an attribute.
This is called attribute splitting and it is a  classic design error. 
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • Color a row in JTable according to specific column value

    I'm having problem setting row color according to specific values set in listData. Color values are also stored inside the listData. Each row has a specific color value assigned to it(either black or blue).
    ColorRenderer is called from table.setDefaultRenderer(Object.class, new ColorRenderer(listData))
    The color values are passed through to ColorRender constructor but not to the getTableCellRendererComponent() method.
    Here is my code. Any help is much appreciated.
    class ColorRenderer extends DefaultTableCellRenderer {
    Color[] colors;
    public ColorRenderer(ListData[] listData) {
    if (listData != null) {
    for (int i=0; i<listData.length; i++) {
         if (listData[i] != null) {
         colors = new Color[listData.length];
         colors[i] = listData.getForegroundColor();
         System.out.println(colors[i].toString());
    else System.out.println("null listData");
    public Component getTableCellRendererComponent (JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    JLabel c =(JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    c.setOpaque(true);
    System.out.println("colors.length: " + colors.length);
    for (int i=0; i<colors.length; i++) {
    if (colors[i] != null) {        
    System.out.println("colors["+i+"]: " + colors[i]);
    c.setForeground(colors[i]);
    } else c.setForeground(Color.black);
    return c;

    Well, first of all, you didn't use the code tokens for your posting. Second, this source won't even compile how you have it. But anyway...
    If you want to change the color of the cell based on the row, assuming you have a matching color in your color list for each row, in your getTableCellRendererComponent() method, just do something like this.
    c.setForeground( colors[row] );

  • Combine 2 specific column values into one column

    Is there an easy solution to combine column values that is in a group?
    In my report I have 1 column group named Activity_Area which has 5 different values Activity 1, Activity2...Activity5.
    Let's say I want to merge Activity 4 and Activity 5 and call it ActivityX and gives me the output as below
    Activity 1 | Activity 2 | Activity 3 | ActivityX

    Hi Jhonny86,
    According to your description, you create a field in database and it contains five values. Then you want to only display four values in report column group, and the last two values should be replaced by “ActivityX”, right?
    In your scenario, you can create an table like below:
    create table Act(id int,activity varchar(99))
    insert into Act select 1,'Activity 1'
    insert into Act select 2,'Activity 2'
    insert into Act select 3,'Activity 3'
    insert into Act select 4,'Activity 4'
    insert into Act select 5,'Activity 5'
    Then query the table with code like below in query designer, then add the field [Act] into the column group.
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support

  • How to get a specific Row based on filter on a specific column value

    Friends,
    I have a requirement to fetch a row, maximum salary of an employee row from employee table using ADF View object, I have a view object with result set based on some critieria, now I have to get a row out of result set which is having maximum employee salary.
    Please put your thoughts or experiences!!
    Thanks

    You should be able to add a transient attribute called maxSalary and use groovy functions to find vo.max(Salary) like -
    https://blogs.oracle.com/adf/entry/using_groovy_aggregate_functions_in
    How to calculate ADF table column [check Laura Akel's post]Then you can create a view criteria which equates the salaryfield to maxSalary and returns just one row.

  • Restricting user access based on a site column value in a document library.

     
    We have a business requirement to show the contents of a document library based on a value (or values) in the site column (or multiple columns). For example, my document library has a custom site column called confidentiality. This
    will have values like restricted, internal and public. Now, based on the AD Group the user belongs to, I should be able to control the access to Restricted or Restricted and Internal files from the document library. We are using SharePoint Online 2010.
    Please suggest the best way to achieve this requirement?

    SharePoint's security model doesn't allow you to specify security based on metadata. You could however create a Sandboxed Solution containing a Feature that registers a custom event receiver on the Document Library. The logic inside this
    Event Receiver would fire after editing item properties (ItemUpdated) to apply item-level permissions based on the rules you need.
    Make sure to read the article below to determine if fine-grained permissions are suitable in your case:
    http://technet.microsoft.com/en-us/library/gg128955.aspx

  • Finding all rows based on previous rows column value diffrence

    I have an interesting requirement. There is a DATE column and a user in a table and I have to find all rows for all the user for which the previous row and current row has time difference of lets say more than 30 minutes. Rows are already sorted by time.
    For example in the following table, we need ID 4 and 6 for user 1.
    ID User date
    1 1 today 1 hour 0 min 0 s
    2 1 today 1 hour 1 min 0 s
    3 1 today 1 hour 29 min 0 s
    *4 1 today 1 hour 59 min 3 s*
    5 1 today 2 hour 10 min 2 s
    *6 1 today 2 hour 50 min 7 s*
    Edited by: user733179 on Mar 5, 2009 12:00 PM

    Hi,
    To get all the users in the result set, outer-join to a table (or subquery, as shown bleow) that has one row per user:
    WITH     got_dif     AS
         SELECT     id,     dt,     usr
         ,     (dt - LAG (dt)
                    OVER ( PARTITION BY  usr
                              ORDER BY          dt
              )             -- difference in days
                  * 24 * 60  AS minutes_dif
         FROM     table_x
    --     WHERE     ...     -- if needed
    ,     all_users     AS
         SELECT DISTINCT  usr
         FROM              table_x
    SELECT     gd.id,     gd.dt,     au.usr
    ,     NVL2 ( gd.usr
              , 'Okay'
              , 'Dif is never > 30'
              )    AS flag
    FROM          all_users
    LEFT OUTER JOIN     got_dif          ON  gd.usr         = au.usr
                                AND gd.minutes_dif > 30
    ;Notice that the test for a 30-minute difference is part of the join condition.
    You don't need the flag column, and you may not want it.
    If you would prefer a separate query of just the users that are not in the original result set, then you can use the original query (modified only slightly) as an EXISTS ior NOT IN sub-query. For example:
    SELECT DISTINCT     usr
    FROM    table_x
    WHERE   usr  NOT IN
         WITH     got_dif     AS
              SELECT     id,     dt,     usr
              ,     (dt - LAG (dt)
                             OVER ( PARTITION BY  usr
                                      ORDER BY          dt
                    )             -- difference in days
                        * 24 * 60  AS minutes_dif
               FROM     table_x
    --          WHERE     ...     -- if needed
         SELECT  usr   -- Only 1 column in SELECT clause
         FROM     got_dif
         WHERE     minutes_dif     > 30
    ;

  • How to insert column values into database as rows

    Hi,
    I have 8 columns and some not null columns. Based on not null columns I want to insert into table as rows. The 8 columns may contain values or no value. If the first column contains data, then I have to insert into one row. if the second column contains data I have to insert a row and in second column. respectively...So How can I insert column values into rows. Can I write 8 insert statements. (OR) is it possible to insert data from columns using where clause.
    Please help me out....
    Thanks in Advance

    Lines Table:
    line_id, orcl_bank_account_num, product_type, service_type, lease_type,
    funding_type, cpi, billing_frequency_unit_cd , annual_due_date ,
    pricing_start_date, pricing_end_date, install_date, contract_end_date ,
    prdct_replacement_cost_amt, cradle_replacement_amt, supranet_contract,
    issuance_fee, board_inactive_date, header_id, creation_date, last_modified_date,
    created_by_nam, modified_by_nam, activeinactive_flg, prdct_bill_amt_yr1,
    prdct_bill_amt_yr2, prdct_bill_amt_yr3, prdct_bill_amt_yr4, prdct_bill_amt_yr5,
    prdct_bill_amt_yr6, prdct_bill_amt_yr7, prdct_bill_amt_yr8, activation_fee_yr1,
    activation_fee_yr2, activation_fee_yr3, activation_fee_yr4, activation_fee_yr5,
    activation_fee_yr6, activation_fee_yr7, activation_fee_yr8,
    In this table the columns structure is :
    -- PRDCT_BILL_AMT_YR (1 to 8) NUMBER(14,4)
    -- ACTIVATION_FEE_YR (1 to 8) NUMBER(8,2)
    I have one more table:
    PRDCT_INS_AMT               NUMBER(14,4)
    ACTIVATION_FEE_AMT          NUMBER(14,4)
    I want to insert prdct_bill_amt_yr (1 to 8) columns data into PRDCT_INS_AMT column. similarly activation_fee (1 to 8) columns data.
    But the data should be inserted based product_type, service_type, lease_type columns values. (These 3 columns may contain upto 45 combinations).

  • How can I sum the values in a given column on sheet 1 i.e. A1:A50 based on the adjacent columns specific value i.e. B1:B50 = "Living Room" on sheet 2

    How can I sum the values in a given column on sheet 1 i.e. A1:A50 based on the adjacent columns specific value i.e. B1:B50 = “Dinning Room” on sheet 2
    For Example:
    SHEET 1
    A
    B
    $50
    Dinning Room
    $800
    Dinning Room
    $300
    Kitchen
    $1,000
    Master Bedroom
    $100
    Dinning Room
    SHEET 2
    Display the total SUM amount of each Project based on Sheet 1
    Project Name
    Total Cost
    Dinning Room
    $950
    Kitchen
    $300

    Would be a good idea to open iWork Formulas and Functions User Guide and search for the description of the function named SUMIF
    The Guide is available for every user thru the Help menu.
    Yvan KOENIG (VALLAURIS, France) jeudi 19 mai 2011 17:32:42
    Please :
    Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • Sorting based on a specific value in Columns

    Hi All,
    Crystal 2008 version I have. And we are connecting to BW queries as source.
    In a crosstab, I want to sort my row values based on a column value.
    For example, in rows I have an element with three values . In column I have only one element(month), with couple of month values. My requirement is to sort rows based on a specific month (Mar'09 for example).
    .....................Jan'09......Feb'09.....Mar'09
    ABC...............10.............323...........33....
    XYZ...............32..............33............11....
    FGH...............5................34.............55...
    But when I try to sort based on the Month, I can not select a specific value(mar'09). And it sorts based on the total value (sum of all months).
    How can I achieve this problem?
    Thanks
    Ozan

    For {Sort Value}, if you wanted to sort on the Jan column, then substitute the field name that your example shows as 10 in row ABC.  For {row value}, substitute the field name that is used in the first column (ABC in the example).
    In other words, take the value that you want to sort on, and put it in front of the value currently displaying as the row header.  Then, sort on the results.
    The purpose of the "000000000.00" is to make the length of the number, when converted to string, a consistent size.  This is needed (a) so you know how many characters to strip off when displaying the row value, and (b) so the records don't sort as 1, 12, 2, 234, 235423, 25, 3, ...
    HTH,
    Carl

  • Custom row-fetch and how to get column values from specific row of report

    Hi -- I have a case where a table's primary key has more than 3 columns. My report on the
    table has links that send the user to a single-row DML form, but of course the automatic
    fetch won't work because 1) I can't set more than 3 item values in the link and 2) the
    auto fetch only handles 2 PK columns.
    1)
    I have written a custom fetch (not sure it's the most elegant, see second question) that is working
    for 3 or few PK columns (it references the 1-3 item values set in the link), but when there are
    more than 3, I don't know how to get the remaining PK column values for the specific row that was
    selected in the report. How can I access that row's report column values? I'll be doing it from the
    form page, not the report page. (I think... unless you have another suggestion.)
    2)
    My custom fetch... I just worked something out on my own, having no idea how this is typically
    done. For each dependent item (database column) in the form, I have a source of PL/SQL
    function that queries the table for the column in question, using the primary key values. It works
    beautifully, though is just a touch slow on my prototype table, which has 21 columns. Is there
    a way to manually construct the fetch statement once for the whole form, and have APEX be smart
    about what items get what
    return values, so that I don't have to write PL/SQL for every item? Because my query data sources
    are sometimes in remote databases, I have to write manual fetch and dml anyway. Just would like
    to streamline the process.
    Thanks,
    Carol

    HI Andy -- Well, I'd love it if this worked, but I'm unsure how to implement it.
    It seems I can't put this process in the results page (the page w/ the link, that has multiple report rows), because the link for the row will completely bypass any after-submit processes, won't it? I've tried this in other conditions; I thought the link went directly to the linked-to page.
    And, from the test of your suggestion that I've tried, it's not working in the form that allows a single row edit. I tried putting this manually-created fetch into a before header process, and it seems to do nothing (even with a hard-coded PK value, just to test it out). In addition, I'm not sure how, from this page, the process could identify the correct PK values from the report page, unless it can know something about the row that was selected by clicking on the link. It could work if all the PK columns in my edit form could be set by the report link, but sometimes I have up to 5 pk columns.
    Maybe part of the problem is something to do with the source type I have for each of the form items. With my first manual fetch process, they were all pl/sql functions. Not sure what would be appropriate if I can somehow do this with a single (page level?) process.
    Maybe I'm making this too hard?
    Thanks,
    Carol

  • Interactive Report - One column based on a list of values

    I have an Interactive Report that's part of a Form with Report. The form works fine, but I have a problem with the interactive report. One of the fields is based on a list of values. That is, the data in the table in the State field has numeric state codes, 1 to 51. The form part has no problem with this, as it's a select list based on a list of values LOV query, so the user selects the actual name of the state.
    The interactive report, however, displays the numeric codes, which is what is actually in the table. I am looking in the column definition for some way to tell it to convert the value to the state name, but I do not see it. There is a List of Values place, but that seems to be for filtering purposes instead of for return vs. display value.
    3.2.

    Tharpa,
    I'm not sure if what I am about to suggest will work in 3.2. However, in 4.1, I am using LOVs with IRRs without any issue.
    For example, if I have an address field of state code, I have a named LOV (LOV_STATE). I go into the report attributes for this column. There, I find a section named "List of Values" In here, I pick the "column filter type" of "Use Named List of Values to Filter Exact Match". (Presumably, this will work with Static List too). When the column is displayed, I see the State name displayed.
    -Joe
    Edited by: Joe Upshaw on Mar 14, 2012 1:58 PM

  • How to restrict a table with its set of data based on a column value in it?

    Hi,
    I have a scenario in which I have to show a set of data of a pivot table by restricting data based on a column value. I am creating BIP report whose source is from BIA ie.RPD. Based on a column value I want to restrict the data being displayed in the table. Since I also want the hidden data in the first table to be displayed in another table in the same report I cannot restrict the data at the query level i.e at RPD or at BIA. For this reason I used
    <?xdofx:if saw3_ = 1?>
    the pivot table
    <?end if?>
    But it does not restrict any data.
    Also I tried using the if condition inside the table before the row level looping happens. But no good show even then.
    How can I forgo this problem?
    Regards,
    The MM

    Hi,
    See : http://download.oracle.com/docs/cd/E12096_01/books/PubUser/T421739T481157.htm#4535373 regarding column and row.
    Regards,
    Colectionaru

  • Filter a tableview based on a column value-Navigation Issues.

    Hi,
    I have a table view with total 99 values. The values are displayed in 10 tabs of the table view with 9 values in each tab.I go to the third tab and select a column value, which triggers an event and filters the result list from 99 to 12.
    I am simply removing the collection and filling it again with fresh values.
    My problem is-when i set the collection with new values, i want the end user to be navigated to the first tab.
    But the user is always navigated to the second tab which has the last three values.
    Is there any way to navigate the user to first tab of table view?
    I have already tried-visibleFirstRow and it is not working.
    Thanks and Regards,
    Rohit

    Hi Ashish,
    You can implement some code in DO_INIT_CONTEXT to filter your Items' BOL collection based on the condition quantity <> 0. I believe the Quantity field is available in the BOL structure.
    Here is a code snippet.
    DATA: lr_col TYPE REF TO if_bol_bo_col,
    DATA: lr_node TYPE REF TO if_bol_bo_property_access.
    lr_node = me->typed_context->CONTEXT NODE->collection_wrapper->get_first( ).
    WHILE lr_node IS BOUND.
    CALL METHOD lr_node->get_properties
    IMPORTING
    es_attributes = ls_struct.
    IF ls_struct-quantity = 0 .
      lr_col->remove( iv_bo = lr_node ).
    ENDIF.
      lr_node = lr_col->get_next( ).
    ENDWHILE.
    Regards,
    Masood Imrani S.

  • Performance operations based on Column values in SQL server 2008

    Hi ,
    I have a table which consist of following columns
    ID    Formula              
    Values                 
    DisplayValue
    1                    
    a*b/100       100*12/100    
          null
    2                    
    b*c/100       
    12*4/100              
    null
    I want to perform operation based on column "Values" and save data after operations in new column Name "Display Value" .i.e I want to get the below result . Can anyone please help.
    ID    Formula              
    Values                 
    DisplayValue
    1                    
    a*b/100       100*12/100    
          12
    2                    
    b*c/100       
    12*4/100             
    0.48
    Thanks for the help.
    Regards, Priti A

    Try this,
    create table #mytable (ID int,Formula varchar(10), [Values] varchar(10), DisplayValue decimal(10,4))
    insert into #mytable values(1 ,'a*b/100','100*12/100',null)
    insert into #mytable values(2 ,'b*c/100','12*4/100',null)
    declare @rowcount int=1
    while @rowcount <= (select max(id) from #mytable)
    begin
    declare @expression nvarchar(max)
    select @expression=[values] from #mytable where id = + @rowcount
    declare @sql nvarchar(max)
    set @sql = 'select @result = ' + @expression
    declare @result decimal(10,4)
    exec sp_executesql @sql, N'@result decimal(10,4) output', @result = @result out
    update #mytable set DisplayValue= @result where id = @rowcount
    set @rowcount=@rowcount+1
    end
    select * from #mytable
    Regards, RSingh

  • FCC error :java.lang.Exception: Column value '   ' too long

    Hi all,
    I am using FCC on receiving File adapter...
    While executing i am getting this error in CC monitor
    com.sap.aii.af.ra.ms.api.RecoverableException: Exception in XML Parser (format problem?):'java.lang.Exception: Message processing failed in XML parser: 'java.lang.Exception: Column value '   ' too long (>1 for 2. column) - must stop',
    i searched in SDN but no luck till now..
    Plz help me out..
    Thanx in advance.

    Hi,
    Check ur FCC parameters,
    File content conversion sites
    /people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1
    /people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2
    /people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
    /people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
    /people/shabarish.vijayakumar/blog/2005/08/17/nab-the-tab-file-adapter
    /people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1
    /people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2
    /people/venkat.donela/blog/2005/06/08/how-to-send-a-flat-file-with-various-field-lengths-and-variable-substructures-to-xi-30
    /people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
    /people/shabarish.vijayakumar/blog/2005/08/17/nab-the-tab-file-adapter
    /people/jeyakumar.muthu2/blog/2005/11/29/file-content-conversion-for-unequal-number-of-columns
    /people/shabarish.vijayakumar/blog/2006/02/27/content-conversion-the-key-field-problem
    /people/michal.krawczyk2/blog/2004/12/15/how-to-send-a-flat-file-with-fixed-lengths-to-xi-30-using-a-central-file-adapter
    /people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
    http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
    Regards,
    Phani.
    Reward points if Helpful

Maybe you are looking for

  • Can All Calendars Stay Bolded

    I'm new to iCal and have inputted all my events, and notice that only the events from one of my colored calendar sections can be highlighted (brighter, bolder colors) at one time (i.e. when I highlight a different colored event in my daily and weekly

  • Flash content will not load in IE7

    My company standard is IE7 I'm charged with developing flv that will auto play on PC from a removable thumb drive. in addition it should be able to launch a url. I'm using CS4 Flash and Dreamweaver developing on a Mac. I've used action script 3 to pr

  • Downgrade from OSX to OS9?

    I currently have OSX 10.4.5 on my Powermac BW, but I'm trying to do a boot install of OS 9, I have both os 9.1, and OS 9.2.1, I do not have the restore disc, and I have tried holding C, which does nothing, as well as zapping pram, which causes OSX to

  • How to read StarOffice Spreadsheet using Oracle Form?

    Hi all I want to read StarOffice spreadsheet with few columns in Oracle forms. I have done this with Microsoft Excel but not with StarOffice. Does anyone have idea regards how to do this? Rgds

  • Reservation Of material against a particular job

    Hi ,       I have a scenarion at my clients place. Here I procure material for different jobs againsat stock. When the material is received it should be reserved for specific job, but the material goes to unrestricted stock & anyone is able to issue