Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Problem with Distinct and Order By when querying csv with .NET System::Data::OleDb::OleDbConnection [modified]

Problem with Distinct and Order By when querying csv with .NET System::Data::OleDb::OleDbConnection [modified]

Scheduled Pinned Locked Moved Database
databasehelpcsharpc++
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    T2102
    wrote on last edited by
    #1

    I need to query a csv file with C++ .NET and get a distinct list which is ordered by multiple criterion. If I write regular SQL, then i get the error "order by clause conflicts with distinct". If I use the prefix "SELECT * FROM ( SELECT" and suffix ")", then the order is lost. My current workaround is to manually modify the results to a distinct set using C++.

    modified on Wednesday, February 10, 2010 5:24 AM

    D 1 Reply Last reply
    0
    • T T2102

      I need to query a csv file with C++ .NET and get a distinct list which is ordered by multiple criterion. If I write regular SQL, then i get the error "order by clause conflicts with distinct". If I use the prefix "SELECT * FROM ( SELECT" and suffix ")", then the order is lost. My current workaround is to manually modify the results to a distinct set using C++.

      modified on Wednesday, February 10, 2010 5:24 AM

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      What is the exact query you are using?

      "No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem

      T 1 Reply Last reply
      0
      • D dan sh

        What is the exact query you are using?

        "No matter how many fish in the sea; it will be so empty without me." - From song "Without me" by Eminem

        T Offline
        T Offline
        T2102
        wrote on last edited by
        #3

        The query with the distinct is below. However, this returns an error unless distinct is removed. I am using Provider=Microsoft.Jet.OLEDB.4.0 SELECT DISTINCT ID_BB_SEC_NUM_DES FROM Curncy_FORWARD2010020801.csv WHERE ID_BB_SEC_NUM_DES LIKE '%HKD%' AND NAME NOT LIKE '%/%' AND NAME NOT LIKE '%+%' AND UCASE(NAME) NOT LIKE '%FWD POINTS%' AND UCASE(NAME) NOT LIKE '%IMPLIED YLD%' AND UCASE(NAME) NOT LIKE '%OUTR%' AND LEN(ID_BB_SEC_NUM_DES) BETWEEN 5 AND 10 AND UCASE(MARKET_SECTOR_DES( = 'CURNCY' AND SECURITY_TYP='FORWARD' AND ID_BB_SEC_NUM_SRC IS NOT NULL AND RIGHT(ID_BB_SEC_NUM_DES,1) IN ('W','M','Y') ORDER BY RIGHT(ID_BB_SEC_NUM_DES,1)<>'W' DESC, RIGHT(ID_BB_SEC_NUM_DES,1), LEFT(RIGHT(ID_BB_SEC_NUM_DES,LEN(ID_BB_SEC_NUM_DES)-3),LEN(ID_BB_SEC_NUM_DES)-4)+0

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups