Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

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.
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page