Mysql distinct search for one column

I would like to use an SQL query to return from a database the first occurence of a data value (DUT's serial number). I have a database that contains the DUT serial number, the test status (i.e. pass or fail), and the date the DUT was tested. Since I am trying to determine the first pass yield for this test lot of DUTs, I want to only query the database for the first occurence (i.e. earliest date DUT was tested), and retunr the test status for this entry. Any recommendations on what type of SQL commadn I could use to get this data?
Below is an example of the database:
DUT SN         TEST STATUS             DATE TESTED
001                Failed                          6-1-2011
001                Passed                        6-2-2011
002                Passed                        6-1-2011
003                Passed                        6-1-2011
004                Failed                          6-2-2011
004                Passed                        6-2-2011
005                Passed                        6-2-2011
THis is the data I would like to extract:
DUT SN         TEST STATUS             DATE TESTED
001                Failed                          6-1-2011
002                Passed                        6-1-2011
003                Passed                        6-1-2011
004                Failed                          6-2-2011
005                Passed                        6-2-2011
As you can see I only want to get the first entry for a serial number. This first entry will be used to determine the first pass yield for the lot of boards.
Thank you in advance for your time and assistance,
Jim
Solved!
Go to Solution.

I don't believe you can do one query to get what you want.  I use this query:
... and then process the results like this:
...to get first-pass yield information.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

Similar Messages

  • In BI Publisher Report of excel output for one column is filled with spaces

    Hello,
    We have issue in BI Publisher report of excel output.
    In Excel output for one column few records are displaying as left alignment
    and few record are displaying as right alignment.
    If you are having any xml tag or any syntax for removing spaces for left side
    Please help on this issue.
    Thanks in Advance.
    Regards,
    Swaraj

    Please post the details of the application release, database version and OS along with BI Publisher.
    Is the issue with all reports or specific one(s) only?
    Do you have the patches in the following docs applied?
    Overview of Available Update Patches for Oracle BI Publisher Enterprise 10g [ID 797057.1]
    Overview of Available Update Patches for Oracle BI Publisher Enterprise 11g [ID 1276869.1]
    Overview of Available Patches for Oracle XML Publisher embedded in the Oracle E-Business Suite [ID 1138602.1]
    BI Publisher 10g RTF Template Changes Alignment Settings for Numbered Lists [ID 1418504.1]
    Thanks,
    Hussein

  • To set a dropdown list for one column in the excel file before downloading

    Hi all,
    I am downloading an excel file which has the format of an internal table with a number of fields. I want to set a dropdown list for one column in the excel file. How can i do this?
    Thanks

    HI ,
    U can use function module " QINT_GET_EXCEL_DATA " ....
    and modify the excel sheet based on ur requirement ......
    Try this ...
    Hope it works
    Thanks
    Shambhu

  • Select List and Popup LoV for one column

    Hello,
    is there a built-in functionality to show a select list and a popup lov for one column similar to "Condition Type" in the condition region when editing a page.

    Hello,
    No, you have to code that yourself. For instance by adding HTML in the Post Element Text field (like <IMG src=... />).
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    http://www.bloggingaboutoracle.org/
    http://www.logica.com/

  • Set custom font size for one column

    hey guys! I am trying to decrease the font-size for one column based on an lov and used
    style="font-size:8pt"It does not work though! Do you have a hint?
    brgds,
    seb

    Hello Seb,
    >> Might it be important whether the column is of type "...based on lov"?
    If by "...based on lov" you mean “Display as Text (based on LOV, does not save state)” the answer is yes. This type of column is not treated as an updatable column (the implementation is by using a regular <td> tag and not the <input> tag) so the Apex engine ignores the Element Attributes field.
    As far as I can tell, this column can only be styled in the query itself (and you need to implement the LOV yourself).
    Another option is to use a select list and disabled it, but the column will appear in gray, and with small font size it doesn’t look that good.
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Forthcoming book about APEX: Oracle Application Express 3.2 – The Essentials and More

  • Search for a column in schema

    Hi ,
    Is there a way to search for a column exist in tables of particular schema ?
    thanks in advance

    user10641405 wrote:
    Hi ,
    Is there a way to search for a column exist in tables of particular schema ?
    You need to clarify "exists". Do you mean exists regardless if you have acces to it or "exists" means you have access to it? For the former use:
    SELECT  OWNER.TABLE_NAME
      FROM  DBA_TAB_COLUMNS
      WHERE OWNER = '<schema name>'
        AND COLUMN_NAME = '<column_name>'
    /For latter use ALL_TAB_COLUMNS instead as it was suggested by others.
    SY.

  • How to boldface the header for ONE column

    hi,
    I want to know how to boldface the header for ONE column. The following will boldface the header for all the columns in the table
    table.getTableHeader().setFont(new java.awt.Font("Dialog", 1, 12));
    Thanks.
    Jrabi

    jtable.getColumnModel().getColumn( indexOfBoldColumn ).setHeaderRenderer( TableCellRenderer aRenderer )

  • Sap.m.Table: How to disable includeItemInSelection for one column?

    Dear UI5 Experts,
    I have used includeItemInSelection method for whole table as it is required for me on selectionChange event in sap.m.Table control.
    Now, I have a requirement where I need to disable that method for one column. Is there a way to disable includeItemInSelection method for only one column in sap.m.Table control. Please Advice.
    Thank you!
    Regards,
    Sai Vellanki

    Hi,
    you can use method oTable.bindAggregation
    Refer example sap.m.Table and see the source code.
    Regards,
    Chandra

  • Search for a column in all SSIS packages in a Folder

    Hi 
    We are changing the datatype of one of a column for a  huge table from INT to BIGINT. All SPs are being changed to accomodate this change. 
    All the SSIS packges havebeen downloaded to a folder. And I need to find the instances of this column in around 250 packages. 
    Is there a quick way to do this instead of opening up each package and looking for the column?
    I dont have access to MSDB so my search should be based o nthe packages inthe folder.
    Thanks 
    rajiv 
    Rajiv

    You can do it using ssis package
    Create a table with two columns
    Table (PackageXML,PackageName)
    one a xml column and another varchar column for this
    1. Add a SSIS package with ForEachLoop container. point to folder containing your SSIS packages. Choose filetype as *.dtsx
    2. Inside loop add a variable to get package names. choose option as Fully qualified (FilePath)
    3. Add another variable and store filename alone extracted from above created variable (FileName)
    4. Add a variable to hold query (Query) and assign an expression to it as
    "INSERT YourTable (PackageXMl,PackageName)
    SELECT *,'" + @[User::FileName] + "'
    FROM OPENROWSET(BULK '" + @[User::FilePath] + "',SINGLE_BLOB) x"
    5. Add a SQL task inside loop, choose SQLSourceType as variable and point to Query variable
    Execute this package. This will cause it to load the code for all packages inside your table
    Once this is done then you can just query the table as below to get package with column reference
    SELECT PackageName
    FROM Table
    WHERE CAST(PackageXML AS varchar(max)) LIKE '%columnname%'
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Is it possible to search only one column in a multi column data store?

    Assume I create a context index using a multi column datastore for the columns first_name, middle_name, and last_name.
    Then I can search all of the columns in the index using contains().
    Is there any way to use contains() to just search one of the columns in a multi column datastore - just last_name for instance?
    In some cases a want to search all of the columns, in other cases just one of the columns.

    Yes, see the doc:
    http://download.oracle.com/docs/cd/B14117_01/text.101/b10730/cdatadic.htm#i1006391
    If you use the default behaviour, then your column data will be separated by XML-like tags.
    <first_name>John</first_name><middle_name>Peter</middle_name><last_name>Doe</last_name>
    You would then need to EITHER define each of these as sections, or use "auto_section_group". You can then search on them using
    ... contains (col, 'peter within middle_name') >0
    See example:
    SQL> drop table t;
    Table dropped.
    SQL> create table t (first varchar2(20), middle varchar2(20), last varchar2(20));
    Table created.
    SQL> insert into t values ('John', 'Peter', 'Doe');
    1 row created.
    SQL> insert into t values ('Peter', 'Frederik', 'Smith');
    1 row created.
    SQL> exec ctx_ddl.drop_preference('my_mcds')
    PL/SQL procedure successfully completed.
    SQL> exec ctx_ddl.create_preference('my_mcds', 'multi_column_datastore')
    PL/SQL procedure successfully completed.
    SQL> exec ctx_ddl.set_attribute('my_mcds', 'columns', 'first,middle,last')
    PL/SQL procedure successfully completed.
    SQL> create index ti on t (first) indextype is ctxsys.context
      2  parameters ('datastore my_mcds section group ctxsys.auto_section_group');
    Index created.
    SQL> select * from t where contains (first, 'peter')>0;
    FIRST               MIDDLE            LAST
    John               Peter            Doe
    Peter               Frederik            Smith
    SQL> select * from t where contains (first, 'peter within middle')>0;
    FIRST               MIDDLE            LAST
    John               Peter            Doe

  • How do I search for one of my bookmarks only within a SUBFOLDER of all of my bookmarks?

    It seems like Firefox only allows you to search for a specific bookmark by searching ALL of your bookmarks and not just limiting a search to a specific sub-folder of bookmarks. I've put a lot of time into bookmarking thousands of sites and i don't want 25 hits on a search result, just the one in the subfolder where I know the specific bookmark is that i'm looking for.
    Is it possible to do this? Amy i missing something?
    Thanks.

    While you wait for a change to the code of Firefox itself...
    You might want to try the [https://addons.mozilla.org/en-US/firefox/addon/show-parent-folder/ Show Parent Folder] extension. It will show the folder name of the bookmark in a column in your search results. I'm assuming you can group by the folder by clicking the column heading, but I haven't tested it.
    If you use the same name in different parts of the hierarchy (e.g., 2013, or Old), the extension's Options dialog allows you to show the full hierarchy.
    Does that help?

  • Count number of distinct values for a column for all tables that contains that column

    Imagine I have one Column called cdperson. With the query below I know which Tables have column cdperson
    select
    t.[name]fromsys.schemassinnerjoin 
    sys.tables 
    tons.schema_id=t.schema_idinnerjoin 
    sys.columnscont.object_id=c.object_idinnerjoin 
    sys.types  
    donc.user_type_id=d.user_type_idwherec.name ='cdperson'
    now I want to know for each table, how many distinct values of cdperson I have and I want the result ordered by the table that has more distinct values (descending)
    Table1                                                                                     
       cdperson                        select distinct(cdperson) = 10
       cdadress
       quant
    Table2 with 
       cdaddress                      (no column cdperson in this table)
       quant
    Table3
       cdperson                        select distinct(cdperson) = 100
       value
    Table 4
       cdperson                        select distinct(cdperson) = 18
       sum
    I want this result ordered by number of distinct cdperson
    table3   100
    table4   18
    table    10
    Thks for your answers

    I had to add schema name to the above script to make it work in AdventureWorks:
    CREATE TABLE #temp(TableName sysname , CNT BIGINT)
    DECLARE @QRY NVARCHAR(MAX);
    SET @qry=(SELECT
    N'INSERT INTO #TEMP SELECT '''+schema_name(t.schema_id)+'.'+T.[name] +''' AS TableName, COUNT (DISTINCT ProductID) DistCount FROM '+
    schema_name(t.schema_id)+'.'+t.[name] +';'
    FROM sys.schemas s INNER JOIN sys.tables t ON s.schema_id=t.SCHEMA_ID
    INNER JOIN sys.columns c ON t.object_id=c.object_id INNER JOIN sys.types d ON c.user_type_id=d.user_type_id
    WHERE c.name ='ProductID'
    FOR XML PATH(''))
    EXEC(@QRY)
    SELECT * FROM #temp ORDER BY TableName
    DROP TABLE #temp
    Production.Product 504
    Production.ProductCostHistory 293
    Production.ProductDocument 31
    Production.ProductInventory 432
    Production.ProductListPriceHistory 293
    Production.ProductProductPhoto 504
    Production.ProductReview 3
    Production.TransactionHistory 441
    Production.TransactionHistoryArchive 497
    Production.WorkOrder 238
    Production.WorkOrderRouting 149
    Purchasing.ProductVendor 211
    Purchasing.PurchaseOrderDetail 211
    Sales.SalesOrderDetail 266
    Sales.ShoppingCartItem 3
    Sales.SpecialOfferProduct 295
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Select distinct('more than one column') from ....

    Why does this sql statement not work:
    select distinct(column_a, column_b, column_c), empno
    from emp;
    How can I 'select distinct' using more than one column.

    Actually, DISTINCT applies to all columns in the result.
    Distinct is not a function, you cannot do distinct(column1, column2, ...).
    As a matter of fact it doesn't make sense to expect distinct applies to only one column, because you do not specify any criteria on how to select the values for the second column.
    A final note: you can do distinct(column1), column2, but this will still apply to both columns!
    Here're some examples that will all return both rows from the set, where set is: (1,1), (1,2):
    select distinct val1, val2
    from
    select 1 as val1, 1 as val2 from dual
    union all
    select 1 as val1, 2 as val2 from dual
    select distinct val1||'-'||val2
    from
    select 1 as val1, 1 as val2 from dual
    union all
    select 1 as val1, 2 as val2 from dual
    select distinct(val1), val2 -- this is very misleading. distinct still applies to both columns
    from
    select 1 as val1, 1 as val2 from dual
    union all
    select 1 as val1, 2 as val2 from dual
    Edited by: user4010726 on Dec 1, 2009 11:06 AM
    Edited by: user4010726 on Dec 1, 2009 11:07 AM

  • Searching for missing column names in a single database.

    I have a database with about 100 tables, database gets generated using entity framework. The application has been enhanced  so users deployed with older version of the application need to upgrade to newer version. The database generated is both versions
    is same name.
    Now, the older version is missing some tables and column names that are in new database.
    Is there a script that can search for missing fields in a single database as described in this situation?
    Below is my script. Basically, nameofdatabase would the database generated and that already existing. If you install the application and database already exits no new database will be created.
    SELECT * FROM (Select TABLE_CATALOG, Table_name,COLUMN_NAME FROM nameofdatabase.INFORMATION_SCHEMA.COLUMNS) a FULL OUTER JOIN (SELECT TABLE_CATALOG, Table_name,COLUMN_NAME FROM nameofdatabase.INFORMATION_SCHEMA.COLUMNS) b ON b.COLUMN_NAME=a.COLUMN_NAME and
    a.TABLE_NAME=b.TABLE_NAME WHERE b.COLUMN_NAME is null or a.COLUMN_NAME is null ;

    There is a great tool called SQLCompare provide by www.red-gate.com
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • ALV grid display the subtotal not getting for one column at the output

    Hi,
    I am working one report ALV grid display and subtotal is not getting for one paricular coulumn.
    Eventhough that column has some values.
    So can anyone give the proper solution.
    Waiting quick response.
    Best Regards,
    Bansi

    Hi
    see this link .
    https://wiki.sdn.sap.com/wiki/display/ABAP/SUBTOTALinALV
    or try this program.
    REPORT zalv.
    DATA:
    t_sflight TYPE TABLE OF sflight,
    fs_sflight TYPE sflight.
    DATA:
    r_container TYPE REF TO cl_gui_custom_container,
    r_grid TYPE REF TO cl_gui_alv_grid.
    *FIELD CATALOG
    DATA:
    t_fcat TYPE lvc_t_fcat,
    fs_fcat TYPE lvc_s_fcat.
    *SORTING THE BASIC LIST
    DATA:
    t_sort TYPE lvc_t_sort,
    fs_sort TYPE lvc_s_sort.
    fs_fcat-fieldname = 'PRICE'.
    fs_fcat-do_sum = 'X'.
    APPEND fs_fcat TO t_fcat.
    fs_sort-spos ='1'.
    fs_sort-fieldname = 'CARRID'.
    fs_sort-down = 'X'.
    fs_sort-group = '*'.
    fs_sort-subtot = 'X'.
    APPEND fs_sort TO t_sort.
    SELECT * FROM sflight INTO TABLE t_sflight.
    CALL SCREEN 100.
    *& Module STATUS_0100 OUTPUT
    MODULE status_0100 OUTPUT.
    SET PF-STATUS 'SCREEN1'.
    SET TITLEBAR 'TITLE1'.ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
    CASE sy-ucomm.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    **& Module HANDLER OUTPUT
    MODULE list OUTPUT.
    CREATE OBJECT r_container
    EXPORTING
    container_name = 'CONTAINER'.
    CREATE OBJECT r_grid
    EXPORTING
    i_parent = r_container.
    CALL METHOD r_grid->set_table_for_first_display
    EXPORTING
    i_structure_name = 'SFLIGHT'
    CHANGING
    it_fieldcatalog = t_fcat
    it_outtab = t_sflight
    it_sort = t_sort.
    ENDMODULE. "list OUTPUT
    Regards
    Hareesh Menon

Maybe you are looking for

  • Bios update for Satellite Pro L750 still on black screen

    Hi, The HDMI, USB, VGA and ethernet ports on the one side of my laptop were not working at all. I rang the Toshiba warranty number and was instructed to update the bios. It restarted straight away and came to the Windows log in screen and I entered m

  • Flash Components and XML Binding

    I just ran through the XML binding Bike Trails tutorial about a hundred times. I can get that to work just fine. But when I try to work with my XML file, it keeps falling apart. I just don't get it! I've been working on it for 2 days and it's still n

  • Amber update problem

    I have 620. I live in Pune,India. I havent received any amber updatevyet though Nokia support page says the update is avilable. Sometimes while searching for update it gives errors. What should I do??

  • Foreign Key reference

    Hi all, I have two tables called PATIENT and PERSON. All persons are not patients but all patients are persons. Now how to define the relation between the two tables? Should PATIENT have foreign key reference to PERSON or should PERSON have foreign k

  • C5100 all in one install option missing

    I am running Windows 8, 32 bit. So the printer has been buggy and I decided to uninstall and re-install it. As I was uninstalling it I was also downloading some files. After I reinstalled the c5100 all in one package from the website I ran the instal