+ Reply to Thread
Results 1 to 3 of 3

Thread: SQL Query in Excel csv using MS Query

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    SQL Query in Excel csv using MS Query

    I have a batch of 12 csv files, one for each month. What I'm trying to do is amalgamate them all into one file with no duplicate data.

    So, I've started in July 09 and created a master sheet. Then I want to query June 09 and only withdraw the records that don't match a column in the master sheet.

    I've tried:-
    Code:
    SELECT DISTINCT `June 2009`.CRMContactId, `May 2009`.ContactName `May 2009`.ClientName, `May 2009`.SchemeName, `May 2009`.IORef, `May 2009`.Provider, `May 2009`.PlanType, `May 2009`.PlanNumber, `May 2009`.LeadPractitionerName
    FROM `May 2009.csv` `May 2009`, `Master Sheet.csv` `Master`
    WHERE (`May 2009`.ContactName='Policy  Check') AND (`May 2009`.PlanNumber Not In (`Master`.PlanNumber))
    
    but it still returns records that so match the Master.PlanNumber column.

    I've also tried using a subquery :-
    Code:
    Not In (SELECT `Master`.PlanNumber FROM `Master Sheet.csv` Master)
    
    and that returns no records when there are some that aren't in the master sheet.

    Any ideas how I can achieve this?

  2. #2
    I like Data Cubes too... Lauramc has a spectacular aura about Lauramc has a spectacular aura about Lauramc's Avatar
    Join Date
    Mar 2008
    Location
    Far Far Away
    Posts
    387
    Real Name
    Laura
    Rep Power
    5

    I would first try running only the inner query and see if that works. Also, I'm not sure if single quotes are used around table names will work in MSQuery. You might try brackets instead of the single quotes, since it is likely that the data between the single quotes can be seen as a string.

    Hopefully that will help.
    "The Enrichment Center is required to remind you that first you will be baked, then there will be cake." - GLaDOS

  3. #3
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Couldn't seem to get the queries to work in Excel.....It just seemed to keep doubling the records, so a spreadsheet that started at 1000 odd rows would end up at 8,000+ rows when it should have been alot less than 1000.

    Just ended up importing each sheet into a MySQL table and dealing with them using an SP in MySQL.

    Stoopid Excel / MS Query....

+ Reply to Thread

Similar Threads

  1. Which query is better among these 2?
    By micky in forum SQL Development
    Replies: 7
    Last Post: July 8th, 2009, 04:13 AM
  2. ASP sql query help ....
    By pmcdonald in forum SQL Development
    Replies: 8
    Last Post: November 7th, 2008, 08:17 PM
  3. Need help with query
    By micky in forum SQL Development
    Replies: 2
    Last Post: October 30th, 2008, 07:01 AM
  4. Query help
    By mehere in forum SQL Development
    Replies: 9
    Last Post: June 6th, 2008, 04:15 PM
  5. SQL VBA Query
    By Jaykappy in forum Microsoft Access
    Replies: 12
    Last Post: May 8th, 2008, 10:30 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO