DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Need Help For Query

  1. #1
    Join Date
    Dec 2006
    Posts
    2

    Need Help For Query

    I need help writing a query to get data off of a table. Here is the table with some sample data:

    SKU STATUS PALLET_L CARTON_L LAST_PICK_DT
    ------------- -------- -------- -------- ---------------
    WM525 A D1237 D1749 20051110:122120
    WM525 A F0736C1 E2106G2 20051011:090419
    WM525 A BW0149A2 M0326E1 20050729:112126
    WM525 A HI0260 ? 20050105:054150

    What I need to do is, find the sku, status, pallet_l, carton_l, last_pick_dt. I need to have only 1 row come back unless the value for status is different for the same sku. Here it is ok to have two different dates.
    This one row needs to be ordered by last_pick_dt, so that the most recent is shown. Now if, either pallet_l or carton_l is null, I need to bring back the next value in that specific column and then differentiate between the two dates to find which date is the most recent.

    Example Results:
    No NULL Values
    SKU STATUS PALLET_L CARTON_L LAST_PICK_DT
    ------------- -------- -------- -------- ---------------
    WM525 A D1237 D1749 20051110:122120

    NULL Values
    SKU STATUS PALLET_L CARTON_L LAST_PICK_DT
    ------------- -------- -------- -------- ---------------
    WM525 A D1237 ? 20051110:122120
    WM525 C D1234 D1486 20051109:122120
    ^-->Should display as follows
    SKU STATUS PALLET_L CARTON_L LAST_PICK_DT
    ------------- -------- -------- -------- ---------------
    WM525 C D1234 D1486 20051110:122120

    Different STATUS's
    SKU STATUS PALLET_L CARTON_L LAST_PICK_DT
    ------------- -------- -------- -------- ---------------
    WM525 A D1237 D1749 20051110:122120
    WM525 C D1234 D1732 20051109:122120

  2. #2
    Join Date
    Jan 2007
    Posts
    27
    What database is this running on? SQL Server? Oracle?

  3. #3
    Join Date
    Dec 2006
    Posts
    2
    Oracle

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center