Max Date Function

Hi,
I have the following columns in a report:
Vendor Name
Trade date
Prod Desc
Order Type
Qty
Gross Amt
I need to display only those rows where trade date = max(trade date).
I am aware of the MAX analytic function, but it keeps giving me an error.
Could someone please let me know how to achieve this scenario.
Thanks.

Hi
As pupppethead mentioned, it doesn't look as though you need a PARTITION BY clause.
A straight MAX(Trade Date) OVER () = Trade Date should suffice. The OVER() tells Discoverer to look at all dates in the query. You will only need a PARTITION BY if you are using Page Items or Group Sorts and you wanted a different date in each set.
By the way, as a word of warning, be very careful not to name items in folders or workbooks using Oracle reserved words. Naming an item as Desc is dangerous because that is the name of the descending switch in an ORDER BY clause of an analytic function. Thus, if you have for example something called ITEM DESC and try to do this:
RANK() OVER(ORDER BY ITEM DESC) you will have serious problems because the database (not Discoverer) will think you want to sort ITEM descending. Either ITEM does not exist and you will get an error or it does exist and you will end up with the sort on the wrong item.
Imagine also if you named something ORDER BY and then place this in a PARTITION BY clause like this:
MAX(Trade Date) OVER (PARTITION BY ORDER BY)
Interesting conundrum, don't you think?
Best wishes
Michael

Similar Messages

  • Max Date function by Group is not catching a Null Date

    I have a query that returns the MAX CLINICALDATE. It is worknig great except if their is no CLINCIALDATE then it doesn't bring that group back and it needs to. Thank you for your help.
    SELECT PERSON.MEDRECNO, MEDICATE.INSTRUCTIONS, PERSON.LASTNAME, PERSON.FIRSTNAME, MEDICATE.STARTDATE, MEDICATE.STOPDATE, MEDICATE.STOPREASON, MEDICATE.DESCRIPTION, PRESCRIB.REFILLS, PRESCRIB.QUANTITY, PRESCRIB.CLINICALDATE
    FROM
         ((ML.MEDICATE MEDICATE
    INNER JOIN ML.PERSON PERSON ON (MEDICATE.PID = PERSON.PID))
         LEFT OUTER JOIN ML.PRESCRIB PRESCRIB ON (MEDICATE.PID = PRESCRIB.PID)     AND (MEDICATE.MID = PRESCRIB.MID))
         LEFT OUTER JOIN ML.USRINFO USRINFO ON (PRESCRIB.PVID = USRINFO.PVID)
    WHERE PERSON.MEDRECNO='20-14-38' AND (MID, CLINICALDATE) IN
    (SELECT MID, MAX(CLINICALDATE) FROM PRESCRIB GROUP BY MID) and (STOPREASON is null or STOPREASON = ' ') and (MEDICATE.STOPDATE = to_date('4700-12-31 00:00:00', 'yyyy/mm/dd hh24:mi:ss'))
    ORDER BY MEDICATE.DESCRIPTION

    As stated when entering the forum, SQL Developer is a tool; you want the SQL And PL/SQL forum instead.
    Regards,
    K.

  • Imbed Date Function????

    Hi,
    I am having trouble with a date function in Oracle Administrator. How do I make max_date a condition (for a case statement)? I am trying to return a value (a ranking) for the most recent ranking date.
    Ie:
    Case
    When Date = Max --I know you can use a Max(date) function but 
    and (another condition) --how do you make that a condition within case
    Then (return value) -- statement?
    Else 0
    End
    Is this a case where I have to import an Oracle Function? Or can I get around this by using a pre-existing function?

    Multiple posting
    Date Function - Holiday?

  • How to find the max data transfer rate(disk speed) supported by mobo?

    I plan on replacing my current HDD with a new and bigger HDD.
    For this I need to know the max data transfer rate(disk speed) that my mobo will support. However, dmidecode is not telling me that. Am I missing something?
    Here's dmidecode:
    # dmidecode 2.11
    SMBIOS 2.5 present.
    80 structures occupying 2858 bytes.
    Table at 0x000F0450.
    Handle 0xDA00, DMI type 218, 101 bytes
    OEM-specific Type
    Header and Data:
    DA 65 00 DA B2 00 17 4B 0E 38 00 00 80 00 80 01
    00 02 80 02 80 01 00 00 A0 00 A0 01 00 58 00 58
    00 01 00 59 00 59 00 01 00 75 01 75 01 01 00 76
    01 76 01 01 00 05 80 05 80 01 00 D1 01 19 00 01
    00 15 02 19 00 02 00 1B 00 19 00 03 00 19 00 19
    00 00 00 4A 02 4A 02 01 00 0C 80 0C 80 01 00 FF
    FF 00 00 00 00
    Handle 0xDA01, DMI type 218, 35 bytes
    OEM-specific Type
    Header and Data:
    DA 23 01 DA B2 00 17 4B 0E 38 00 10 F5 10 F5 00
    00 11 F5 11 F5 00 00 12 F5 12 F5 00 00 FF FF 00
    00 00 00
    Handle 0x0000, DMI type 0, 24 bytes
    BIOS Information
    Vendor: Dell Inc.
    Version: A17
    Release Date: 04/06/2010
    Address: 0xF0000
    Runtime Size: 64 kB
    ROM Size: 4096 kB
    Characteristics:
    PCI is supported
    PNP is supported
    APM is supported
    BIOS is upgradeable
    BIOS shadowing is allowed
    ESCD support is available
    Boot from CD is supported
    Selectable boot is supported
    EDD is supported
    Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
    3.5"/720 kB floppy services are supported (int 13h)
    Print screen service is supported (int 5h)
    8042 keyboard services are supported (int 9h)
    Serial services are supported (int 14h)
    Printer services are supported (int 17h)
    ACPI is supported
    USB legacy is supported
    BIOS boot specification is supported
    Function key-initiated network boot is supported
    Targeted content distribution is supported
    BIOS Revision: 17.0
    Handle 0x0100, DMI type 1, 27 bytes
    System Information
    Manufacturer: Dell Inc.
    Product Name: OptiPlex 755
    Version: Not Specified
    UUID: 44454C4C-5900-1050-8033-C4C04F434731
    Wake-up Type: Power Switch
    SKU Number: Not Specified
    Family: Not Specified
    Handle 0x0200, DMI type 2, 8 bytes
    Base Board Information
    Manufacturer: Dell Inc.
    Product Name: 0PU052
    Version:
    Handle 0x0300, DMI type 3, 13 bytes
    Chassis Information
    Manufacturer: Dell Inc.
    Type: Space-saving
    Lock: Not Present
    Version: Not Specified
    Asset Tag:
    Boot-up State: Safe
    Power Supply State: Safe
    Thermal State: Safe
    Security Status: None
    Handle 0x0400, DMI type 4, 40 bytes
    Processor Information
    Socket Designation: CPU
    Type: Central Processor
    Family: Xeon
    Manufacturer: Intel
    ID: 76 06 01 00 FF FB EB BF
    Signature: Type 0, Family 6, Model 23, Stepping 6
    Flags:
    FPU (Floating-point unit on-chip)
    VME (Virtual mode extension)
    DE (Debugging extension)
    PSE (Page size extension)
    TSC (Time stamp counter)
    MSR (Model specific registers)
    PAE (Physical address extension)
    MCE (Machine check exception)
    CX8 (CMPXCHG8 instruction supported)
    APIC (On-chip APIC hardware supported)
    SEP (Fast system call)
    MTRR (Memory type range registers)
    PGE (Page global enable)
    MCA (Machine check architecture)
    CMOV (Conditional move instruction supported)
    PAT (Page attribute table)
    PSE-36 (36-bit page size extension)
    CLFSH (CLFLUSH instruction supported)
    DS (Debug store)
    ACPI (ACPI supported)
    MMX (MMX technology supported)
    FXSR (FXSAVE and FXSTOR instructions supported)
    SSE (Streaming SIMD extensions)
    SSE2 (Streaming SIMD extensions 2)
    SS (Self-snoop)
    HTT (Multi-threading)
    TM (Thermal monitor supported)
    PBE (Pending break enabled)
    Version: Not Specified
    Voltage: 0.0 V
    External Clock: 1333 MHz
    Max Speed: 5200 MHz
    Current Speed: 2666 MHz
    Status: Populated, Enabled
    Upgrade: Socket LGA775
    L1 Cache Handle: 0x0700
    L2 Cache Handle: 0x0701
    L3 Cache Handle: Not Provided
    Serial Number: Not Specified
    Asset Tag: Not Specified
    Part Number: Not Specified
    Core Count: 2
    Core Enabled: 2
    Thread Count: 2
    Characteristics:
    64-bit capable
    Handle 0x0700, DMI type 7, 19 bytes
    Cache Information
    Socket Designation: Not Specified
    Configuration: Enabled, Not Socketed, Level 1
    Operational Mode: Write Back
    Location: Internal
    Installed Size: 32 kB
    Maximum Size: 32 kB
    Supported SRAM Types:
    Other
    Installed SRAM Type: Other
    Speed: Unknown
    Error Correction Type: None
    System Type: Data
    Associativity: 8-way Set-associative
    Handle 0x0701, DMI type 7, 19 bytes
    Cache Information
    Socket Designation: Not Specified
    Configuration: Enabled, Not Socketed, Level 2
    Operational Mode: Varies With Memory Address
    Location: Internal
    Installed Size: 6144 kB
    Maximum Size: 6144 kB
    Supported SRAM Types:
    Other
    Installed SRAM Type: Other
    Speed: Unknown
    Error Correction Type: Single-bit ECC
    System Type: Unified
    Associativity: <OUT OF SPEC>
    Handle 0x0800, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: PARALLEL
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: DB-25 female
    Port Type: Parallel Port PS/2
    Handle 0x0801, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: SERIAL1
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: DB-9 male
    Port Type: Serial Port 16550A Compatible
    Handle 0x0802, DMI type 126, 9 bytes
    Inactive
    Handle 0x0803, DMI type 126, 9 bytes
    Inactive
    Handle 0x0804, DMI type 126, 9 bytes
    Inactive
    Handle 0x0805, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: USB1
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Access Bus (USB)
    Port Type: USB
    Handle 0x0806, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: USB2
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Access Bus (USB)
    Port Type: USB
    Handle 0x0807, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: USB3
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Access Bus (USB)
    Port Type: USB
    Handle 0x0808, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: USB4
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Access Bus (USB)
    Port Type: USB
    Handle 0x0809, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: USB5
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Access Bus (USB)
    Port Type: USB
    Handle 0x080A, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: USB6
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Access Bus (USB)
    Port Type: USB
    Handle 0x080B, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: USB7
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Access Bus (USB)
    Port Type: USB
    Handle 0x080C, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: USB8
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Access Bus (USB)
    Port Type: USB
    Handle 0x080D, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: ENET
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: RJ-45
    Port Type: Network Port
    Handle 0x080E, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: MIC
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Mini Jack (headphones)
    Port Type: Audio Port
    Handle 0x080F, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: LINE-OUT
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Mini Jack (headphones)
    Port Type: Audio Port
    Handle 0x0810, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: LINE-IN
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Mini Jack (headphones)
    Port Type: Audio Port
    Handle 0x0811, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: HP-OUT
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: Mini Jack (headphones)
    Port Type: Audio Port
    Handle 0x0812, DMI type 8, 9 bytes
    Port Connector Information
    Internal Reference Designator: MONITOR
    Internal Connector Type: None
    External Reference Designator: Not Specified
    External Connector Type: DB-15 female
    Port Type: Video Port
    Handle 0x090A, DMI type 9, 13 bytes
    System Slot Information
    Designation: SLOT1
    Type: x1 Proprietary
    Current Usage: In Use
    Length: Long
    Characteristics:
    PME signal is supported
    Handle 0x0901, DMI type 126, 13 bytes
    Inactive
    Handle 0x0902, DMI type 9, 13 bytes
    System Slot Information
    Designation: SLOT2
    Type: 32-bit PCI
    Current Usage: Available
    Length: Long
    ID: 2
    Characteristics:
    5.0 V is provided
    3.3 V is provided
    PME signal is supported
    Handle 0x0903, DMI type 126, 13 bytes
    Inactive
    Handle 0x0904, DMI type 126, 13 bytes
    Inactive
    Handle 0x0905, DMI type 126, 13 bytes
    Inactive
    Handle 0x0906, DMI type 126, 13 bytes
    Inactive
    Handle 0x0907, DMI type 126, 13 bytes
    Inactive
    Handle 0x0908, DMI type 126, 13 bytes
    Inactive
    Handle 0x0A00, DMI type 10, 6 bytes
    On Board Device Information
    Type: Video
    Status: Disabled
    Description: Intel Graphics Media Accelerator 950
    Handle 0x0A02, DMI type 10, 6 bytes
    On Board Device Information
    Type: Ethernet
    Status: Enabled
    Description: Intel Gigabit Ethernet Controller
    Handle 0x0A03, DMI type 10, 6 bytes
    On Board Device Information
    Type: Sound
    Status: Enabled
    Description: Intel(R) High Definition Audio Controller
    Handle 0x0B00, DMI type 11, 5 bytes
    OEM Strings
    String 1: www.dell.com
    Handle 0x0D00, DMI type 13, 22 bytes
    BIOS Language Information
    Language Description Format: Long
    Installable Languages: 1
    en|US|iso8859-1
    Currently Installed Language: en|US|iso8859-1
    Handle 0x0F00, DMI type 15, 29 bytes
    System Event Log
    Area Length: 2049 bytes
    Header Start Offset: 0x0000
    Header Length: 16 bytes
    Data Start Offset: 0x0010
    Access Method: Memory-mapped physical 32-bit address
    Access Address: 0xFFF01000
    Status: Valid, Not Full
    Change Token: 0x00000018
    Header Format: Type 1
    Supported Log Type Descriptors: 3
    Descriptor 1: POST error
    Data Format 1: POST results bitmap
    Descriptor 2: System limit exceeded
    Data Format 2: System management
    Descriptor 3: Log area reset/cleared
    Data Format 3: None
    Handle 0x1000, DMI type 16, 15 bytes
    Physical Memory Array
    Location: System Board Or Motherboard
    Use: System Memory
    Error Correction Type: None
    Maximum Capacity: 8 GB
    Error Information Handle: Not Provided
    Number Of Devices: 4
    Handle 0x1100, DMI type 17, 27 bytes
    Memory Device
    Array Handle: 0x1000
    Error Information Handle: Not Provided
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 1024 MB
    Form Factor: DIMM
    Set: None
    Locator: DIMM_1
    Bank Locator: Not Specified
    Type: DDR2
    Type Detail: Synchronous
    Speed: 667 MHz
    Manufacturer: AD00000000000000
    Handle 0x1101, DMI type 17, 27 bytes
    Memory Device
    Array Handle: 0x1000
    Error Information Handle: Not Provided
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 1024 MB
    Form Factor: DIMM
    Set: None
    Locator: DIMM_3
    Bank Locator: Not Specified
    Type: DDR2
    Type Detail: Synchronous
    Speed: 667 MHz
    Handle 0x1102, DMI type 17, 27 bytes
    Memory Device
    Array Handle: 0x1000
    Error Information Handle: Not Provided
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 1024 MB
    Form Factor: DIMM
    Set: None
    Locator: DIMM_2
    Bank Locator: Not Specified
    Type: DDR2
    Type Detail: Synchronous
    Speed: 667 MHz
    Handle 0x1103, DMI type 17, 27 bytes
    Memory Device
    Array Handle: 0x1000
    Error Information Handle: Not Provided
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 1024 MB
    Form Factor: DIMM
    Set: None
    Locator: DIMM_4
    Bank Locator: Not Specified
    Type: DDR2
    Type Detail: Synchronous
    Speed: 667 MHz
    Handle 0x1300, DMI type 19, 15 bytes
    Memory Array Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x000FDFFFFFF
    Range Size: 4064 MB
    Physical Array Handle: 0x1000
    Partition Width: 1
    Handle 0x1400, DMI type 20, 19 bytes
    Memory Device Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x0007FFFFFFF
    Range Size: 2 GB
    Physical Device Handle: 0x1100
    Memory Array Mapped Address Handle: 0x1300
    Partition Row Position: 1
    Interleave Position: 1
    Interleaved Data Depth: 1
    Handle 0x1401, DMI type 20, 19 bytes
    Memory Device Mapped Address
    Starting Address: 0x00080000000
    Ending Address: 0x000FDFFFFFF
    Range Size: 2016 MB
    Physical Device Handle: 0x1101
    Memory Array Mapped Address Handle: 0x1300
    Partition Row Position: 1
    Interleave Position: 1
    Interleaved Data Depth: 1
    Handle 0x1402, DMI type 20, 19 bytes
    Memory Device Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x0007FFFFFFF
    Range Size: 2 GB
    Physical Device Handle: 0x1102
    Memory Array Mapped Address Handle: 0x1300
    Partition Row Position: 1
    Interleave Position: 2
    Interleaved Data Depth: 1
    Handle 0x1403, DMI type 20, 19 bytes
    Memory Device Mapped Address
    Starting Address: 0x00080000000
    Ending Address: 0x000FDFFFFFF
    Range Size: 2016 MB
    Physical Device Handle: 0x1103
    Memory Array Mapped Address Handle: 0x1300
    Partition Row Position: 1
    Interleave Position: 2
    Interleaved Data Depth: 1
    Handle 0x1410, DMI type 126, 19 bytes
    Inactive
    Handle 0x1800, DMI type 24, 5 bytes
    Hardware Security
    Power-On Password Status: Enabled
    Keyboard Password Status: Not Implemented
    Administrator Password Status: Enabled
    Front Panel Reset Status: Not Implemented
    Handle 0x1900, DMI type 25, 9 bytes
    System Power Controls
    Next Scheduled Power-on: *-* 00:00:00
    Handle 0x1B10, DMI type 27, 12 bytes
    Cooling Device
    Type: Fan
    Status: OK
    OEM-specific Information: 0x0000DD00
    Handle 0x1B11, DMI type 27, 12 bytes
    Cooling Device
    Type: Fan
    Status: OK
    OEM-specific Information: 0x0000DD01
    Handle 0x1B12, DMI type 126, 12 bytes
    Inactive
    Handle 0x1B13, DMI type 126, 12 bytes
    Inactive
    Handle 0x1B14, DMI type 126, 12 bytes
    Inactive
    Handle 0x2000, DMI type 32, 11 bytes
    System Boot Information
    Status: No errors detected
    Handle 0x8100, DMI type 129, 8 bytes
    OEM-specific Type
    Header and Data:
    81 08 00 81 01 01 02 01
    Strings:
    Intel_ASF
    Intel_ASF_001
    Handle 0x8200, DMI type 130, 20 bytes
    OEM-specific Type
    Header and Data:
    82 14 00 82 24 41 4D 54 01 01 00 00 01 A5 0B 02
    00 00 00 00
    Handle 0x8300, DMI type 131, 64 bytes
    OEM-specific Type
    Header and Data:
    83 40 00 83 14 00 00 00 00 00 C0 29 05 00 00 00
    F8 00 4E 24 00 00 00 00 0D 00 00 00 02 00 03 00
    19 04 14 00 01 00 01 02 C8 00 BD 10 00 00 00 00
    00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00
    Handle 0x8800, DMI type 136, 6 bytes
    OEM-specific Type
    Header and Data:
    88 06 00 88 5A 5A
    Handle 0xD000, DMI type 208, 10 bytes
    OEM-specific Type
    Header and Data:
    D0 0A 00 D0 01 03 FE 00 11 02
    Handle 0xD100, DMI type 209, 12 bytes
    OEM-specific Type
    Header and Data:
    D1 0C 00 D1 78 03 07 03 04 0F 80 05
    Handle 0xD200, DMI type 210, 12 bytes
    OEM-specific Type
    Header and Data:
    D2 0C 00 D2 F8 03 04 03 06 80 04 05
    Handle 0xD201, DMI type 126, 12 bytes
    Inactive
    Handle 0xD400, DMI type 212, 242 bytes
    OEM-specific Type
    Header and Data:
    D4 F2 00 D4 70 00 71 00 00 10 2D 2E 42 00 11 FE
    01 43 00 11 FE 00 0F 00 25 FC 00 10 00 25 FC 01
    11 00 25 FC 02 12 00 25 FC 03 00 00 25 F3 00 00
    00 25 F3 04 00 00 25 F3 08 00 00 25 F3 0C 07 00
    23 8F 00 08 00 23 F3 00 09 00 23 F3 04 0A 00 23
    F3 08 0B 00 23 8F 10 0C 00 23 8F 20 0E 00 23 8F
    30 0D 00 23 8C 40 A6 00 23 8C 41 A7 00 23 8C 42
    05 01 22 FD 02 06 01 22 FD 00 8C 00 22 FE 00 8D
    00 22 FE 01 9B 00 25 3F 40 9C 00 25 3F 00 09 01
    25 3F 80 A1 00 26 F3 00 A2 00 26 F3 08 A3 00 26
    F3 04 9F 00 26 FD 02 A0 00 26 FD 00 9D 00 11 FB
    04 9E 00 11 FB 00 54 01 23 7F 00 55 01 23 7F 80
    5C 00 78 BF 40 5D 00 78 BF 00 04 80 78 F5 0A 01
    A0 78 F5 00 93 00 7B 7F 80 94 00 7B 7F 00 8A 00
    37 DF 20 8B 00 37 DF 00 03 C0 67 00 05 FF FF 00
    00 00
    Handle 0xD401, DMI type 212, 172 bytes
    OEM-specific Type
    Header and Data:
    D4 AC 01 D4 70 00 71 00 03 40 59 6D 2D 00 59 FC
    02 2E 00 59 FC 00 6E 00 59 FC 01 E0 01 59 FC 03
    28 00 59 3F 00 29 00 59 3F 40 2A 00 59 3F 80 2B
    00 5A 00 00 2C 00 5B 00 00 55 00 59 F3 00 6D 00
    59 F3 04 8E 00 59 F3 08 8F 00 59 F3 00 00 00 55
    FB 04 00 00 55 FB 00 23 00 55 7F 00 22 00 55 7F
    80 F5 00 58 BF 40 F6 00 58 BF 00 EB 00 55 FE 00
    EA 00 55 FE 01 40 01 54 EF 00 41 01 54 EF 10 ED
    00 54 F7 00 F0 00 54 F7 08 4A 01 53 DF 00 4B 01
    53 DF 20 4C 01 53 7F 00 4D 01 53 7F 80 68 01 56
    BF 00 69 01 56 BF 40 FF FF 00 00 00
    Handle 0xD402, DMI type 212, 152 bytes
    OEM-specific Type
    Header and Data:
    D4 98 02 D4 70 00 71 00 00 10 2D 2E 2D 01 21 FE
    01 2E 01 21 FE 00 97 00 22 FB 00 98 00 22 FB 04
    90 00 11 CF 00 91 00 11 CF 20 92 00 11 CF 10 E2
    00 27 7F 00 E3 00 27 7F 80 E4 00 27 BF 00 E5 00
    27 BF 40 D1 00 22 7F 80 D2 00 22 7F 00 45 01 22
    BF 40 44 01 22 BF 00 36 01 21 F1 06 37 01 21 F1
    02 38 01 21 F1 00 39 01 21 F1 04 2B 01 11 7F 80
    2C 01 11 7F 00 4E 01 65 CF 00 4F 01 65 CF 10 D4
    01 65 F3 00 D5 01 65 F3 04 D2 01 65 FC 00 D3 01
    65 FC 01 FF FF 00 00 00
    Handle 0xD403, DMI type 212, 157 bytes
    OEM-specific Type
    Header and Data:
    D4 9D 03 D4 70 00 71 00 03 40 59 6D 17 01 52 FE
    00 18 01 52 FE 01 19 01 52 FB 00 1A 01 52 FB 04
    1B 01 52 FD 00 1C 01 52 FD 02 1D 01 52 F7 00 1E
    01 52 F7 08 1F 01 52 EF 00 20 01 52 EF 10 21 01
    52 BF 00 22 01 52 BF 40 87 00 59 DF 20 88 00 59
    DF 00 E8 01 66 FD 00 E9 01 66 FD 02 02 02 53 BF
    00 03 02 53 BF 40 04 02 53 EF 00 05 02 53 EF 10
    06 02 66 DF 00 07 02 66 DF 20 08 02 66 EF 00 09
    02 66 EF 10 17 02 66 F7 00 18 02 66 F7 08 44 02
    52 BF 40 45 02 52 BF 00 FF FF 00 00 00
    Handle 0xD800, DMI type 126, 9 bytes
    Inactive
    Handle 0xDD00, DMI type 221, 19 bytes
    OEM-specific Type
    Header and Data:
    DD 13 00 DD 00 01 00 00 00 10 F5 00 00 00 00 00
    00 00 00
    Handle 0xDD01, DMI type 221, 19 bytes
    OEM-specific Type
    Header and Data:
    DD 13 01 DD 00 01 00 00 00 11 F5 00 00 00 00 00
    00 00 00
    Handle 0xDD02, DMI type 221, 19 bytes
    OEM-specific Type
    Header and Data:
    DD 13 02 DD 00 01 00 00 00 12 F5 00 00 00 00 00
    00 00 00
    Handle 0xDE00, DMI type 222, 16 bytes
    OEM-specific Type
    Header and Data:
    DE 10 00 DE C1 0B 00 00 10 05 19 21 01 00 00 01
    Handle 0x7F00, DMI type 127, 4 bytes
    End Of Table
    Hdparm also does not tell me the max data transfer rate (disk speed) of my current drive although this link : www.wdc.com/en/library/sata/2879-001146.pdf  says that it is 3.0Gb/s
    and here's hdparm -I /dev/sda
    /dev/sda:
    ATA device, with non-removable media
    Model Number: WDC WD800JD-75JNC0
    Firmware Revision: 06.01C06
    Standards:
    Supported: 6 5 4
    Likely used: 8
    Configuration:
    Logical max current
    cylinders 16383 16383
    heads 16 16
    sectors/track 63 63
    CHS current addressable sectors: 16514064
    LBA user addressable sectors: 156250000
    Logical/Physical Sector size: 512 bytes
    device size with M = 1024*1024: 76293 MBytes
    device size with M = 1000*1000: 80000 MBytes (80 GB)
    cache/buffer size = 8192 KBytes
    Capabilities:
    LBA, IORDY(can be disabled)
    Standby timer values: spec'd by Standard, with device specific minimum
    R/W multiple sector transfer: Max = 16 Current = 8
    Recommended acoustic management value: 128, current value: 254
    DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5
    Cycle time: min=120ns recommended=120ns
    PIO: pio0 pio1 pio2 pio3 pio4
    Cycle time: no flow control=120ns IORDY flow control=120ns
    Commands/features:
    Enabled Supported:
    * SMART feature set
    Security Mode feature set
    * Power Management feature set
    * Write cache
    * Look-ahead
    * Host Protected Area feature set
    * WRITE_BUFFER command
    * READ_BUFFER command
    * DOWNLOAD_MICROCODE
    SET_MAX security extension
    Automatic Acoustic Management feature set
    * Device Configuration Overlay feature set
    * Mandatory FLUSH_CACHE
    * SMART error logging
    * SMART self-test
    * Gen1 signaling speed (1.5Gb/s)
    * Host-initiated interface power management
    * SMART Command Transport (SCT) feature set
    * SCT Long Sector Access (AC1)
    * SCT LBA Segment Access (AC2)
    * SCT Error Recovery Control (AC3)
    * SCT Features Control (AC4)
    * SCT Data Tables (AC5)
    Security:
    Master password revision code = 65534
    supported
    not enabled
    not locked
    frozen
    not expired: security count
    not supported: enhanced erase
    Checksum: correct
    Last edited by Inxsible (2011-03-27 04:40:49)

    I just checked my BIOS and my current setting is set at IDE although it also mentions that the default should be AHCI. Currently I have a dual boot of Windows 7 (need it for Tax software) and Arch
    So I guess, when I get the new HDD, I will first set it to AHCI and then install the OSes on it. See if NCQ helps any, and if not I will turn it back and re-install (if I have to). I am planning to have Windows only in virtualbox in the new drive.
    Anyhoo, while I was in the BIOS I found two things which I had questions about :
    1) Under Onboard Devices --> Integrated NIC , my setting is currently set at "On w/PXE" and it says the default should be just "On". Would it be ok to change it back to On since its a single machine and its not booting an OS on any server. I just don't want to have to re-install anything now since I will be doing that in the new HDD.
    2) How would I know whether my BIOS would support a 64 bit OS in Virtualbox? I checked some setting under Virtualization, but they weren't very clear.
    I will edit this post and let you know exactly what settings were present under the Virtualization sub-section.

  • Max Data Rate: AGP 2x?!

    Bought myself a new MSI-KT6 Delta a few weeks ago (MSI-6590), and have had no problems until now.
    First up, my GeForce 4 Ti 4600 decided to suddenly die. Random characters on the screen in text mode, flickery colours and corrupt pixels everywhere. Windows wouldn't detect it properly anymore.
    Bought a new Powercolor Radeon 9600 XT with VIVO today. Downloaded the new drivers, and loaded up some Battlefield, all good. Runs nice and smooth. COD, Quake 3, etc, no problems at all.
    Halo, however... BAD. Even with the basic graphics settings and no Pixel-Shading, it runs at 4 frames a second, and nothing I do changes this, from lowest to highest with Pixel-Shaders 2.0. Although there's a visual difference, it's just as slow.
    So I loaded up ATI control Panel and used SmartGart to enable 8x and Fast-Writes... Rebooted, lots of flickering screen, and Windows XP is now software-rendering everything (Transparent menus take 100% CPU to fade in)
    Wait for SmartGart to fix my graphics again, and it's all back to 4x and no fast-write.
    Loaded up SiSoft Sandra, to check the settings in there...
    Mainboard: "Max Data Rate: AGP 2x"
    AGP Card: "Data Transfer Modes Support: 1x, 2x"
    "AGP Bus is unused or AGP card not fully AGP compatible"
    Er... should this be right? BIOS wont let me select an AGP speed, it's "Auto" and I can't select it. I'm a little concerned that my Motherboard may have been damaged! I'll go get the latest Halo Patch, but it doesn't change the fact that I can't use 8x or Fast-Write.
    I'm a little apprehensive about flashing my BIOS, made more difficult by the fact that I have no working floppy drive.
    CPU: AMD 2600+
    RAM: 2x512mb DDR 333MHz Kingston
    AlphaGremlin

    Well, I updated the VIA drivers, and an updated Sandra. AGP is running at 8x, and Fast-Writes are enabled! I don't know what the hell SmartGart was going on about, but it appears to slunk away and disappeared completely from the ATI control panel since the last reinstall of drivers.
    So there's one problem solved... but I don't know what's up with Halo... I can set it to the lowest settings and it still runs like an elephant with three legs, even with the -useff option for Fixed Function shaders... ah well, that's a matter for another forum, eh?
    Interesting note: Sandra reports my 120gb drive as 605gb... should I be trusting it?
    AlphaGremlin

  • How to get max date in variable using  dynamic query

    Hi,
    the following code gets all dates from sourcetable i want only max date , so i thought max function can be added and it will work
    but still i have to create a table for one value(scalar) can get it in any other effeciant way.
    declare
    TYPE date_string IS TABLE OF VARCHAR(1000);
    date_obj date_string;
    BEGIN
    EXECUTE IMMEDIATE 'SELECT to_char('''||day1||'-'||month1||'-'||year1||''') FROM '||source_schema||'.'|| sourcetable ||'' bulk collect INTO date_obj;
    FOR indx IN date_obj.FIRST..date_obj.LAST loop
    dbms_output.put_line(
    date_obj(indx));
    END loop;
    DBMS_OUTPUT.PUT_LINE('Sample output');
    END;
    yours sincerely

    944768 wrote:
    the following code gets all dates from sourcetableNo it doesn't. What is the datatype of day1, month1 and year1? They cannot be DATE datatypes otherwise your TO_CHAR would fail with all that concatenation going on. And your TO_CHAR is returning a VARCHAR2 datatype... so you cannot say that it is getting all dates... because there are no DATE datatypes returned. It's getting a lot of strings, but certainly not DATE's.
    i want only max date , so i thought max function can be added and it will work You can use the MAX function on a DATE datatype, but not on strings (at least not in the way you intend it to work).
    Converting it to a DATE before doing the MAX will allow you to get the maximum date (assuming the date format is correct)
    EXECUTE IMMEDIATE 'SELECT max(to_date(to_char('''||day1||'-'||month1||'-'||year1||'''),''DD-MM-YYYY'')) FROM  '||source_schema||'.'|| sourcetable ||'' bulk collect INTO date_obj;Then you will find have the other issues...
    a) you are then going to be fetching your DATEs in to a collection of VARCHAR strings. (Not even VARCHAR2, very poor). This should be DATE datatype
    b) you are bulk collecting into a collection, when you are using MAX which will return a single value in your example
    And you really should address the design issues:
    c) why are day, month and year, not being stored in the database as a single DATE datatype in the first place
    d) why does your code not know the name of the table it's querying requiring the use of very poor dynamic SQL techniques.
    e) why are you loading data in a collection in expensive PGA memory... what can't you do in SQL that requires you to collect the data into memory first?

  • SSAS Max date in grouped set of records

    I have a query where I need to pull back the latest risk assessment rating for a record, but need to do this for all records from the query. I have MS
    SSRS Report Builder (V3) as the only way to access this data and no access to modify the underlying cubes which are provided by a supplier.
    My basic MDX which pulls out the data needed is the following:
    SELECT
    NON EMPTY {
    [Measures].[No of Investigations]
    } ON COLUMNS,
    NON EMPTY { (
    [Investigation Indicators and Text Fields].[Investigation Reference Number].[Investigation Reference Number].ALLMEMBERS *
    [Risk Assessment Rating].[Risk Rating].[Risk Rating].ALLMEMBERS *
    [Risk Assessment Completed Date].[Date].[Date].ALLMEMBERS *
    [Risk Assessment Completed Time].[Time HHMM].[Time HHMM].ALLMEMBERS
    ) } ON ROWS
    FROM [Investigation]
    which leaves my Date and Time needing to be concatenated. I have carried this out as a calculated field but am unable to then test for a max value as it gives me an error around using an aggregate function.
    Is anyone able to provide me with any ideas on how to carry this out, either via the MDX statement
    or subsequently. Ideally I would like to be able to create the results in two ways - one with all records and a marker showing which is the latest assessment, and one which just pulls back the subset via MDX.
    For clarity the source system holds Investigation records as the core item of interest, and these can have multiple risk assessments attached to them (of different types). I need to return the latest risk assessment against each investigation. If at all possible
    it would be good to return all investigations, with or without risk assessments, as the missing records need to be quality assured. 
    Thanks for any help, ideas or pointers on this. 

    Hi Steven,
    According to your description, you want to marker the Max date in the assemessments, right?
    Generally, when creating a date dimension in a SSAS project, the dimension members were sorted in date order. So the last date is the max date. We can get the last date using ClosingPeriod function. Here is a sample function for you reference.
    with member [measures].[a]
    as
    ClosingPeriod ([Date].[Calendar].[Date],[Date].[Calendar].currentmember).name
    select {[measures].[a]} on 0,
    [Date].[Calendar].[Month].members on 1
    from
    [Adventure Works]
    Reference
    http://msdn.microsoft.com/en-us/library/ms145584.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to retreive the max data length of a column

    Hello All,
    I know how to do a select to get the max data length of a column it is this :
    SELECT MAX(LENGTH(COLUMN_NAME) FROM table.
    However, I need this information combined with my SQL that returns the Data_type and length from the USER_TAB_COLUMNS. So taking the emp example if the ename column was 50 as VARCHAR2 but the max data entered in it was just 20 I want the information like this:
    SELECT COLUMN_NAME, DATA_LENGTH, and the Max length of 20
    FROM USER_TAB_COLUMNS WHERE TABLE_NAME='EMP';
    I don't know how to get the Max Length of the Column in this table. Can anyone suggest me a hint? An Inline view maybe?
    Thanks

    Still not sure about your requirements, but how about this
    SQL> CREATE OR REPLACE FUNCTION get_max_length(p_table in varchar2, p_col in varchar2) return pls_integer
      2  is
      3    v_cnt pls_integer;
      4  begin
      5    execute immediate 'select max(length('||p_col||')) from '||p_table into v_cnt;
      6    return v_cnt;
      7  end get_max_length;
      8  /
    Function created.
    SQL>
    SQL> SELECT COLUMN_NAME,
      2         DATA_LENGTH,
      3         get_max_length(TABLE_NAME, COLUMN_NAME) max_length
      4  FROM USER_TAB_COLUMNS
      5  WHERE TABLE_NAME='EMP'
      6  AND DATA_TYPE like '%CHAR%'
      7  ;
    COLUMN_NAME                    DATA_LENGTH MAX_LENGTH
    ENAME                                   10          6
    JOB                                      9          9
    SQL>

  • Count(*) with group by max(date)

    SQL> select xdesc,xcust,xdate from coba1 order by xdesc,xcust,xdate;
    XDESC XCUST XDATE
    RUB-A 11026 01-JAN-06
    RUB-A 11026 05-JAN-06
    RUB-A 11026 08-JAN-06
    RUB-A 11027 10-JAN-06
    RUB-B 11026 02-JAN-06
    RUB-B 11026 08-JAN-06
    RUB-B 11026 09-JAN-06
    RUB-C 11027 08-JAN-06
    I want to make sql that result :
    XDESC     COUNT(*)
    RUB-A     2
    RUB-B 1
    RUB-C 1
    Criteria : GROUPING: XDESC XCUST AND MAX(DATE)
    bellow mark *** that was selected in count.
    XDESC XCUST XDATE
    RUB-A 11026 01-JAN-06
    RUB-A 11026 05-JAN-06
    RUB-A 11026 08-JAN-06 ***
    RUB-A 11027 10-JAN-06 ***
    ---------------------------------------------------------COUNT RUB-A = 2
    RUB-B 11026 02-JAN-06
    RUB-B 11026 08-JAN-06
    RUB-B 11026 09-JAN-06 ***
    ---------------------------------------------------------COUNT RUB-B = 1
    RUB-C 11027 08-JAN-06 ***
    --------------------------------------------------------COUNT RUB-C = 1
    Can Anybody help ?
    I tried :
    select xdesc,max(xdate),count(max(xdate)) from coba1 group by xdesc
    ERROR at line 1:
    ORA-00937: not a single-group group function
    Thank

    This one is duplicate. see the following link
    Count(*) with group by max(date)
    Thanks

  • In mdx how to get max date for all employees is it posible shall we use group by in mdx

    in mdx how to get max date for all employees is it posible shall we use group by in mdx
    example
    empno  ename date
    1         hari        12-01-1982
    1         hari        13-06-2000
    by using above data i want to get max data

    Hi Hari3109,
    According to your description, you want to get the max date for the employees, right?
    In your scenario, do you want to get the max date for all the employees or for each employee? In MDX, we have the Max function to achieve your requirement. You can refer to Naveen's link or the link below to see the details.
    http://www.sqldbpros.com/2013/08/get-the-max-date-from-a-cube-using-mdx/
    If this is not what you want, please provide us more information about the structure of you cube, so that we can make further analysis.
    Regards,
    Charlie Liao
    TechNet Community Support

  • I want the max date but only look at rows with a certain category value.

    I want a way to get the max date but only look at rows with a certain category value - ignoring the other rows.  My detail table contains expenditures including date (col A) and category (col D) the number of rows will increase with expenditures over time.  My summary table will have a cell for each category and display the last expense date for that category using a functionality that I must ask of you, dear community.
    I am using the latest numbers on an iPad (4) with IOS6.
    Secondarily, I would like to add another cell in the summery table with the value (col E) of the last expense for each category.
    Thank you,
    Warren

    ...later...
    With the addition of an auxiliary column to the Main table, a second header row to the Most recent table, and a minor modification to the formula on the second table, the tables can handle a range of dates set by entering the first and last date into A1 abd B1 respectively of the summary table, Most recent.
    Note that the selected range, shown with a green background in the auxiliary column, does not contain any category B expenses. Using LOOKUP, this would result in a repeat of the January 6 expense bering listed in this row. Switching to VLOOKUP, which can be set to require an exact match, allows the result shown—if there are no expenses in a given category, the formula returns "none" (or whatever message you substitute for "none" in the formula in that column).
    Formulas:
    Main::A2: =IF(OR(B<Most recent :: $A$1,B>Most recent :: $B$1),"x"&E,E)
    Fill down to the end of column A.
    This column must be located on the left side of the table (ie. must be column A), but may be hidden.
    Most recent::A2: =IFERROR(VLOOKUP($D,Main :: $A:$D,COLUMN()+1,FALSE),"none")
    "FALSE" will display as "Exact match" in Numbers's formula editor.
    Fill down to the end of the table and right to column C.
    Regards,
    Barry

  • SQL Command to select MAX(date) & Max(time)

    My am having a really hard time getting a sql command to return data with the max(date) & max(time) combination. I think I need a sub query but can not figure it out. I have looked all over the internet but still don't understand it. Below is my command which returns the max date & max time but they are not from the same row of data. Please help.
    SELECT  "labor"."order-no", "labor"."oper-no", MAX("labor"."end-date") AS myDate, Max("labor"."end-time") AS myTime
    FROM   "E940LIVE"."PUB"."tm-log" "labor"
    WHERE  "labor"."order-no"='73153-bc' AND "labor"."company"='01'
    GROUP BY  "labor"."order-no", "labor"."oper-no"

    Progress does not support the DATEADD function. Waht if I forget the number is time and look at it just as a number. Here is my data and what I have tried (again I don't understand the multiple select concept yet).
    Data
    oper-no   end-date    end-time
      20      2/2/2010     41,975
      30      2/3/2010     45,906
      30      2/16/2010    32,941
      40      2/4/2010     46,099
      40      2/4/2010     50,227
      40      2/4/2010     59,466
      40      2/4/2010     62,024
      40      2/16/2010    43,838
      60      2/17/2010    32,679
      90      2/25/2010    35,270
    SQL Command
    SELECT a."oper-no", a."end-time", a."end-date"
    FROM   "E940LIVE"."PUB"."tm-log" a, (SELECT "end-time", max("end-date") AS max_date FROM "E940LIVE"."PUB"."tm-log" WHERE  "order-no"='73153-bc' AND "company"='01' GROUP BY "end-date", "end-time") b
    WHERE  a."end-time" = b."end-time" AND a."end-date" = b.max_date AND a."order-no"='73153-bc' AND a."company"='01'
    Result
    oper-no   end-date     end-time
      20      2/2/2010      41,975
      30      2/3/2010      45,906
      40      2/4/2010      50,227
      40      2/4/2010      46,099
      40      2/4/2010      59,466
      40      2/4/2010      62,024
      30      2/16/2010     32,941
      40      2/16/2010     43,838
      60      2/17/2010     32,679
      90      2/25/2010     35,270
    Desired Result
    oper-no   end-date    end-time
      20      2/2/2010     41,975
      30      2/16/2010    32,941
      40      2/16/2010    43,838
      60      2/17/2010    32,679
      90      2/25/2010    35,270
    Thanks for any and all help!
    Wayne

  • SQL Help getting Max() date....

    Hi gurus, Here is my situation:
    Here is the sample data:
    Policy_Id Policy-Exp_Dt COl_1
    123_____10/30/2008 __ 333
    123_____ 09/25/2008___445
    123_____ 08/30/2008___443
    Here i have to get the Policy-Exp_Dt from the second row; In other words for all rows which have a similar Policy_Id i should first find out the max(Policy-Exp_Dt) and get the next smallest available date to that.
    I have tried using
    select Policy_Id, COl_1, Policy_Exp_Dt from
    table_1
    where Policy-Exp_Dt = (select max(Policy-Exp_Dt)-1 from
    table_1 a
    where a.policy_id = table_1.policy_id)
    but here i am getting the value = 10/30/2008 - 1 which is 10/29/2008 but i need the value 9/25/2008 which is the next available date less than the max() date.
    Please Advise.
    Edited by: user521009 on Jan 9, 2009 1:56 PM

    I thought to use lag - maybe not as appropriate a ranking functions.
    Also we have a case where there is only One record for a policy - exclude this I guess!
    drop table Max_but_One;
    create table Max_but_One
      Policy_Id      integer      not null,
      Policy_Expires date         not null,
      Policy_Note    varchar2(20) not null
    -- Standard data
    insert into Max_but_One values (123, to_date('30-08-2008','dd-mm-yyyy'), 'First note');
    insert into Max_but_One values (123, to_date('25-09-2008','dd-mm-yyyy'), 'Second note');
    insert into Max_but_One values (123, to_date('30-10-2008','dd-mm-yyyy'), 'Third note');
    -- Standard data again for double check
    insert into Max_but_One values (223, to_date('01-11-2008','dd-mm-yyyy'), 'First note');
    insert into Max_but_One values (223, to_date('02-11-2008','dd-mm-yyyy'), 'Second note');
    -- Only one record for a policy!
    insert into Max_but_One values (323, to_date('01-12-2008','dd-mm-yyyy'), 'First note');
    -- Two or more records for a policy both having the same date which is prior to the max
    insert into Max_but_One values (423, to_date('10-12-2008','dd-mm-yyyy'), 'First note');
    insert into Max_but_One values (423, to_date('10-12-2008','dd-mm-yyyy'), 'Second note');
    insert into Max_but_One values (423, to_date('11-12-2008','dd-mm-yyyy'), 'Third note');
    break on Policy_ID
    select Policy_Id, Policy_Expires, Policy_Note
      from Max_but_One
    order by Policy_Id, Policy_Expires
    POLICY_ID POLICY_EX POLICY_NOTE
           123 30-AUG-08 First note
               25-SEP-08 Second note
               30-OCT-08 Third note
           223 01-NOV-08 First note
               02-NOV-08 Second note
           323 01-DEC-08 First note
           423 10-DEC-08 First note
               10-DEC-08 Second note
               11-DEC-08 Third note
    -- Max Policy_Expires
    select t.*
      from (select Policy_Id, Policy_Expires, Policy_Note
                  ,max(Policy_Expires) over (partition by Policy_Id) as Max_Policy_Expires
              from Max_but_One
           ) t
    where t.Policy_Expires = t.Max_Policy_Expires
    POLICY_ID POLICY_EX POLICY_NOTE          MAX_POLIC
           123 30-OCT-08 Third note           30-OCT-08
           223 02-NOV-08 Second note          02-NOV-08
           323 01-DEC-08 First note           01-DEC-08
           423 11-DEC-08 Third note           11-DEC-08
    -- Using LAG
    select t.Policy_Id
          ,t.Prior_Policy_Expires as Policy_Expires
          ,t.Prior_Policy_Note    as Policy_Note
      from (select Policy_Id, Policy_Expires, Policy_Note
                  ,max(Policy_Expires) over (partition by Policy_Id) as Max_Policy_Expires
                ,lag(Policy_Expires) over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Expires
                  ,lag(Policy_Note)    over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Note
              from Max_but_One
           ) t
    where t.Policy_Expires = t.Max_Policy_Expires
    POLICY_ID POLICY_EX POLICY_NOTE
           123 25-SEP-08 Second note
           223 01-NOV-08 First note
           323
           423 10-DEC-08 Second note
    -- To exclude the single record policy then add and t.Prior_Policy_Expires is not null
    select t.Policy_Id
          ,t.Prior_Policy_Expires as Policy_Expires
          ,t.Prior_Policy_Note    as Policy_Note
      from (select Policy_Id, Policy_Expires, Policy_Note
                  ,max(Policy_Expires) over (partition by Policy_Id) as Max_Policy_Expires
                ,lag(Policy_Expires) over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Expires
                  ,lag(Policy_Note)    over (partition by Policy_Id order by Policy_Expires) as Prior_Policy_Note
              from Max_but_One
           ) t
    where t.Policy_Expires = t.Max_Policy_Expires
       and t.Prior_Policy_Expires is not null
    POLICY_ID POLICY_EX POLICY_NOTE
           123 25-SEP-08 Second note
           223 01-NOV-08 First note
           423 10-DEC-08 Second note
    -- 423 is randomly picked here - could equally have got {423, 10-DEC-08, First note}

  • Transactions between Min and Max dates

    Hey all,
    I have a requirement to extract data between min(transdate) and max(transdate), i got to do this using a single query, i used two queries, ie. 1 select for selecting the max and min dates and my second query to get the transactions. Can some one give me an idea to solve this, as Max & Min functions are not allowed in the where clause.
    Thanks in Advance
    - Eric

    Why single fetch if you want effeciency then use analytic function
    SQL> SELECT empno,ename,hiredate FROM
      2  (SELECT empno,ename,hiredate,MAX(hiredate) OVER (ORDER BY empno) m,
      3          MIN(hiredate) OVER (ORDER BY empno) mi FROM emp)
      4  WHERE hiredate BETWEEN mi AND m;The least and greatest function returns the smallest and greatest value in a list of expressions.
    The syntax for the least function is:
    least( expr1, expr2, ... )
    Khurram

  • Data Federator Universe Date Functions

    Hi,
    I created a Data Federator Universe from target tables (Source Tables from: Sql Server 2005 and Oracle 10g). Now, I want to create a object in the universe: "Days between 2 dates"(coming from 2 different target tables). I don't see any other date functions other than CURDATE(). How to create my object?
    Alternatively, Can I create a caliculated column in the existing target table? For Example, I want to create a new column "Days between 2 Dates" from 2 different tables by using a formula in Default mapping of the target table.
    Thanks & Regards,
    Peter

    Hi Amit,
    Thanks for your reply.
    Ok. So, Universe on top of Data Federator has limited functionality.
    And, other option you mentioned is on report level. I am creating an adhoc universe and I have few objects which will calculate days between 2 dates coming from 2 different tables.
    But, how can I achieve this on Data Federator level. I have no function there to find Days Between 2 dates. I see lot of time and date functions but not the one I required. Also, I added a column in the target table and tried to apply the formula there in the default mapping area. But, I see only the selected target table. I need another date column from another table, which is not displayed in the default mapping area.
    How can I achieve this?
    Regards,
    -Peter

Maybe you are looking for

  • Webservice development in Webdynpro

    Hi,          I want to develop a webservice in webdynpro for consuming BAPI(BAPI_MATERIAL_AVAILABILITY). Can someone provide me the related document to reach this requirement? Thanks, Kundan

  • Cant re install icloud on Windows 7 32bit, transform path invalid

    Hi everybody. I have been trying to reinstall icloud on my Windows 7 32bit pc, but everytime i try to install i get this error: 'Error applying transforms. Verify that the specified transform paths are valid' And then the installer shuts down. Does a

  • I have a table with info and would like to select an item from that table

    Hi I have a table with info (course info that I searched for) and would like to select an item from that table to use for further use in my application. It must work more or less like the tree structure where I can use an On Action select. In other w

  • Dealing with Swing Layouts

    I have a collection of small panels with fixed size (around 50x50), and a main panel with size around 600x480. At run time I need to show this collection of panels on my main panel. Based on your experience, what would be the best layout to show them

  • XML Forms in EP 7.0

    Hi,      Our application uses a customised XML Form that we developed in EP 6.0. This form has the HTML Editor as one of its UI elements, which worked fine in EP 6.0.      But our Portal was upgraded to EP 7.0, after which the table buttons in the to