+ Reply to Thread
Results 1 to 3 of 3

returning data from microsoft query

  1. #1
    Registered User
    Join Date
    09-06-2009
    Location
    Christchurch, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    7

    returning data from microsoft query

    hi,
    I have a query which is giving me some trouble when returning the data from ms query.
    The query was written in mysql query browser and returns 2 columns of data - a date and a number.
    MS Query correctly processes the query but when the data is returned to excel only the second column is returned.

    Here is the query:

    SELECT
    (SELECT
    max(l.the_date)
    FROM
    nc_view_date_functions AS l
    WHERE
    l.week_of_year = d.week_of_year
    AND l.yyyy = d.yyyy
    ) AS week_end_date,
    count(r.consent_id) AS weekly_count
    FROM
    rg_resource_consents AS r
    INNER JOIN nc_view_date_functions AS d
    ON r.application_date = d.the_date
    GROUP BY
    d.yyyy, d.week_of_year;


    Can anyone shed any light on this for me?

    Many thanks
    Last edited by mintmin; 09-08-2009 at 07:24 PM. Reason: change to solved

  2. #2
    Registered User
    Join Date
    09-06-2009
    Location
    Christchurch, New Zealand
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: returning data from microsoft query

    Hi all,

    I have solved this one now - the issue was that excel did not like the way the subquery data was being returned. By using a CAST( AS DATE) around the entire subquery things now work as required.

    Correct query:
    SELECT
    CAST((SELECT max(l.the_date) FROM nc_view_date_functions AS l WHERE l.week_of_year = d.week_of_year AND l.yyyy = d.yyyy ) AS DATE) AS week_end_date,
    count(r.consent_id) AS weekly_count
    FROM rg_resource_consents AS r
    INNER JOIN nc_view_date_functions AS d ON r.application_date = d.the_date
    GROUP BYd.yyyy, d.week_of_year;


    Many thanks.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: returning data from microsoft query

    Thank you for taking the time to post your resolution - this is sure to help someone in the future who may stumble across your post whilst trying to resolve their own issue(s).

    Incidentally please also mark thread as solved (see FAQ / How To for more info.)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1