Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:15:35+00:00 2026-06-09T20:15:35+00:00

I have stuck in small query. There is a table named Table_Activities. Table_Activities (

  • 0

I have stuck in small query. There is a table named Table_Activities.

Table_Activities (Act_id, Date, Activity_name, description).

We need to generate a report out of this. User will choose the month and year for which he wants to generate the report from drop down list.

We need to display All the activities for that month and year group by Activity name.

Example – User Chooses June and 2012.

Report will be-

Gardening

01/06/2012 - They have planted 100 trees.
14/06/2012 - something
27/06/2012 - something

Training

02/06/2012 - Detail description
15/06/2012 - something
28/06/2012 - something

My question is what will be the mysql query to fetch data in this format??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:15:36+00:00Added an answer on June 9, 2026 at 8:15 pm
    select `Date`,description from tm_activities 
    where month(`Date`)='6' and year(`Date`)='2012' 
    order by Activity_name,`date` 
    

    To return an exact format as indicated in your question, please try below:

    select concat(if(actdate='',activity_name,date_format(actdate,'%d/%m/%y')),if(description<>'',concat(' - ',description),'')) as labelm from
    (
    (select ActDate,description,activity_name from tm_activities where month(ActDate)='6' and year(ActDate)='2012' 
    ) 
    union all
    (Select distinct '','',activity_name from tm_activities where month(ActDate)='6' and year(ActDate)='2012')
    )m order by activity_name,actdate
    ;
    

    SQL FIDDLE HERE.

    Output as below:

    Gardening
    01/06/12 - They have planted 100 trees.
    27/06/12 - Gar 2
    Training
    12/06/12 - Training 1
    28/06/12 - Traning 2
    30/06/12 - Traning 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in MS Access database and need to create a query
i have a small problem with my script and i'm stuck... I need to
I am stuck at a small problem. I have this button within a form
I have a table generated from some PHP code that lists a SMALL amount
I have a set S of small trees S[i] which I need to find
I am currently stuck on a small problem. I have a List View which
I am stuck in a small thing. I have a data frame in R
I'm stuck on a small but tricky problem since yesterday. What I have is
I have given a diagram of my current small problem that I need help
I'm implementing a small feature and kind of stuck. I have a button to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.