Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

combining 2 queries into 1

Discussion in 'Information Technology' started by red6000, Jul 28, 2006.

  1. red6000

    red6000
    Expand Collapse
    Guest

    Hi, Is it possible to write code so that 1 query gives the same as the 2
    seperate queries below, thanks:

    SELECT QuestionData.Question, Count(QuestionData.Question) AS
    Number_of_Times_Asked
    FROM QuestionData
    GROUP BY QuestionData.Question
    ORDER BY Count(QuestionData.Question) DESC;
    =======================
    SELECT QuestionData.Rootcause, Count(QuestionData.Rootcause) AS
    Number_of_Rootcause
    FROM QuestionData
    GROUP BY QuestionData.Rootcause
    ORDER BY Count(QuestionData.Rootcause) DESC;


    I ultimately want 1 report to show the data from the above (and other
    queries). I have tried the subreport tool, but that just really wasn't
    working out for me so i'm trying a different approach.

    Thanks.
     
  2. Loading...

    Similar Threads Forum Date
    Importance of Hukamnama - Some Queries Sikh Sikhi Sikhism Jun 14, 2009
    Queries History of Sikhism Oct 26, 2006

  3. Allen Browne

    Allen Browne
    Expand Collapse
    Guest

    You can use a UNION query to combine data from 2 sources, e.g.:

    SELECT QuestionData.Question AS TheTopic,
    Count(QuestionData.Question) AS TheCount,
    "Question" AS TheType
    FROM QuestionData
    GROUP BY QuestionData.Question
    UNION ALL
    SELECT QuestionData.Rootcause AS TheTopic,
    Count(QuestionData.Rootcause) AS TheCount,
    "RootCause" AS TheType
    FROM QuestionData
    GROUP BY QuestionData.Rootcause
    ORDER BY TheCount DESC;

    UNION queries cannot be displayed graphically, and are not updatable.

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia.
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    "red6000" <red1000002001@yahoo.com> wrote in message
    news:44c66832$0$3515$ed2619ec@ptn-nntp-reader01.plus.net...
    > Hi, Is it possible to write code so that 1 query gives the same as the 2
    > seperate queries below, thanks:
    >
    > SELECT QuestionData.Question, Count(QuestionData.Question) AS
    > Number_of_Times_Asked
    > FROM QuestionData
    > GROUP BY QuestionData.Question
    > ORDER BY Count(QuestionData.Question) DESC;
    > =======================
    > SELECT QuestionData.Rootcause, Count(QuestionData.Rootcause) AS
    > Number_of_Rootcause
    > FROM QuestionData
    > GROUP BY QuestionData.Rootcause
    > ORDER BY Count(QuestionData.Rootcause) DESC;
    >
    >
    > I ultimately want 1 report to show the data from the above (and other
    > queries). I have tried the subreport tool, but that just really wasn't
    > working out for me so i'm trying a different approach.
     

Share This Page