Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

  • Newbies

Hi I have been searching all over for an answer to this. Simply put I have a table (members) with fields (branches, gender) and a heap of others what I need is through a SQL query to get the following for a certain date. Here is a pic(capture1) of what I mean. I need a list of the branches with the male/female numbers and totals. I have managed half of it but cannot get the males/females to display together. I hope someone can help asap. Thanks so much, in the meantime I'll keep trying...Regards

 

post-109325-0-19183200-1374211381_thumb.

We can't help you with a SQL query without knowing more about the relational structure of your solution. What fields do you have in what tables that this is drawing from? What have you tried so far, and what result did you get with that?

  • Author
  • Newbies

We can't help you with a SQL query without knowing more about the relational structure of your solution. What fields do you have in what tables that this is drawing from? What have you tried so far, and what result did you get with that?

So far, The fields are all from one table (members13). The data is being pulled from the fields memnum (membership number), Branch (name of the branch), Gender (male/female) and the current month from a variable input. I have tried using :-

SELECT Branch, COUNT(*)

FROM members13

GROUP BY Branch

which gives me a list of the branches and the total members for each branch.

have also tried:-

SELECT Branch, COUNT(*)

FROM members13

WHERE Gender = 'Male'

GROUP BY Branch

which gives me a list of the branches with all the male totals.

I need this in 1 query (if possible) or the easiest way to get the results below:

BRANCH - TOTAL MALES - TOTAL FEMALES - TOTAL

branch1               20                         18                  38

branch2               44                          21                 65

etc. 

Hope this helps

You can do it in query, but not with one SELECT.  So for each gender you need to embed one SELECT...WHERE and one "master" SELECT around the whole thing to include the branch.  So your query will have three SELECTs in it.

actually this should work:

 

 

"SELECT 
branch,
COUNT(*) AS totalCount,
SUM( case when gender = 'F' then 1 else 0 end) as females,
SUM( case when gender = 'M' then 1 else 0 end) as males 
FROM theData 
GROUP BY branch"

Nice query, Wim! Yes that should work really well. :)

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.