Query to Total Attendance by Months
I need the following totals for each student based on the schools that they are enrolled for each month July through June.
Total Days Suspended from each school
Attendance Table Columns - Absent Date, Absent Code, Pupil_Number, School (Absent Codes for suspended = 3)
Total Days Present at each school - Days Enrolled at each school minus Days Suspended minus Absences
Totals
Takes the first day that a student is enrolled (counts the days that the school is in session and the student is not marked absent) Student must be enrolled during the time frame for that month.
Total Days Absent - Total days absent minus suspensions
Examples
Student enrolls in school 11111 on 7/15/2011
Student withdraws from School 11111 on 11/15/2011
Student enrolls in school 22222 on 11/20/2011
Total Days Present should be totaled for each student for each month that they are in a school.
I need 1 row of data for the above student for each month that contains total days suspended, total days present and total days absent.
Pupil Number School Month Totals Days Suspended Total Days Absent Total Days Present
1234 11111 07 0 0 0
1234 11111 08 0 0 4 (school days 4)
1234 11111 09 3 1 16 (schools days 20 - 3-1)
1234 11111 10 0 1 18 (school days 19 - 1)
1234 11111 11 1 1 7 (student enrolled at school A 9 days -1-1)
1234 22222 11 0 1 10 (student enrolled at school B 11 days -1)
1234 22222 12 1 2 17 (school B 20-1-2)
1234 22222 01 0 0 20
Thanks for your help.
>
Hi and welcome to the forums.
Please post DDL and DML with suitable records. Please post the result you want and the logic you used
to derive this result.
Please also use the [ code ] tags for DDL, DML and SQL and possibly desired results- it makes your posts more readable.
Also, take the time to read the forum FAQ and also the "sticky" thread by BluShadow at the top of the list of posts
on this forum's home page.
Take the time to help us to help you. These forums are a great resource and if you follow the guidelines, this will
enable you to get the most out of them.
HTH,
Paul...
Similar Messages
-
Query returns data from previous month. Need to have it return data for the entire year
This is the part of the query that returns data by month:
(YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)AND MONTH(`rereport`.`market_reports_5`.start_date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH))
How can I get it to return data for the year.
TIYHow about omitting the MONTH part:
(YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
ABAP Query Quantity totals wrongly - M.Type 101+, 102-
Hi Friends,
Could any one help me in this? I created an ABAP Query for the combination of T.codes MB51 & MB52. When I see the total qty for the item which has GR and Goods return document.........say first by 101 I rerceive 5 nos and using 122 returns 3 nos. Here Query shows total is 8nos instead of 2 nos.
The same way correnponding price also shows for 8nos instead 2 nos.
Kind Regards,
Sankar.KHi Sankar,
You can use MSEG-SHKZG field for +(plus)/-(minus) indicator where 'H' is -(minus) and 'S' is +(plus).
I hope this can answer your problem.
Regards
Gunawan -
SQL query to get last 6 months records neglect the current month
Hi All;
I need help with
sql query to get last 6 months records neglect the current month
Any help much appreciated
Thanks
Pradnya07SELECT <> FROM tbl WHERE dt >=dateadd(month,-6,GETDATE())
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
please tell me how to get total days in month by calendar:
suppose i pass these parameters in calendar:=
Calendar c1=new GregorianCalendar(2005,1,6);
means it is feb 2005
now i want to find the No of days in current month:
it should give 28 .
please tell how to get.progarmatically i know.
i want APIHi,
I don't know if you got it working or not, but I was looking for the same thing and I found the following at this address
http://javaalmanac.com/egs/java.util/GetDaysInMonth.html
// Create a calendar object of the desired month
Calendar cal = new GregorianCalendar(1999, Calendar.FEBRUARY, 1);
// Get the number of days in that month
int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); // 28
// Try month in a leap year
cal = new GregorianCalendar(2000, Calendar.FEBRUARY, 1);
days = cal.getActualMaximum(Calendar.DAY_OF_MONTH); // 29 -
Re: Statistics Query for Total runtimes for Process Chain incorrect
Hi Guys,
I am building a Query for Total runtimes for Process Chain Statistics. I used the Cube 0TCT_MC21 for Query - 0TCT_MC21_Q0101.
I dragged in Keyfigure section - startdate, end date, Start time are all correct and fine but the End time (0TCTENDTIM) is coming incorrect. Is something else i should use to get the End time?
Please let me know if any suggestions?
RegardsJust check if the end times are in GMT ?? usually happens with timestamps....
-
ABAP Query SUB-TOTALS by Month
Hi,
I am making an ABAP Query and I am trying to create sub-totals per month.
EX. Quantity Date
1 01/01/2008
2 01/02/2008
sub-total 3
1 02/01/2008
sub-total 1
does anyone know how i can do this? (create sub-totals based on the date field)
Thanks!I dont think standard ALV subtotalling will do like this. But there is one workaround
I would suggest you to have one more column named Month. In that column save the month for that row. Then do the subtotalling based on that field Month instead of date field.
Hope this will help
cheers
Kothand -
[Q] Query for outstanding payment per month
I have data like this:
Bill: $100
In January, I paid $50
In Febuary, I paid $30
In March, I paid $20
I used 2 tables (table A and table B)
Table A used to save total amount of the bill. Table B used to save how much I paid the bills. Table A Primary Key is the Foreign Key for Table B.
I need to make a report like this:
In January the report will be:
Bill: $100
Payment1: $50
In Febuary:
Bill: $100
Payment1: $50
Payment2: $30
In March:
Bill: $100
Payment1: $50
Payment2: $30
Payment3: $20
In May it won't appear because it already paid in March.
This is my Query:
SELECT A.BILL, A.BILL_DATE, B.PAYMENT, B.PAYMENT_DATE
FROM TABLE_A AS A
LEFT JOIN TABLE_B AS B ON A.BILL_NO = B.BILL_NO
WHERE MONTH(A.BILL_DATE) <= @PERIOD_MONTH AND YEAR(A.BILL_DATE) = @PERIOD_YEARThanks for answering, but I just tried and I don't think its the result.
This is my table structure:
CREATE TABLE BILL
BILL_ID INT INDENTITY NOTNULL
BILL_DATE DATETIME
BILL_AMOUNT NUMERIC(10,2)
BILL_BALANCE NUMERIC(10,2)
CREATE TABLE PAYMENT
PAYMENT_ID INT IDENTITY NOTNULL
BILL_ID INT
PAYMENT_DATE DATETIME
PAYMENT_AMOUNT NUMERIC(10,2)
)INSERT INTO @BILL VALUES(1,'2014-01-01',100,0)PAYMENT 1INSERT INTO @PAYMENT VALUES(1,1,'2014-01-02',50)
UPDATE BILL SET BILL_BALANCE = BILL_BALANCE + 50 WHERE BILL_ID = 1PAYMENT 2INSERT INTO @PAYMENT VALUES(1,1,'2014-02-01',30)
UPDATE BILL SET BILL_BALANCE = BILL_BALANCE + 30 WHERE BILL_ID = 1
Everytime I paid, BILL_BALANCE = BILL_BALANCE + PAYMENT_AMOUNT
In january:
BILL_AMOUNT = $100
BILL_BALANCE = $50
In Feb:
BILL_BALANCE = $80 etc.
at first I have 11 Payment data, after I'm using cross join, it become 780 data. -
How to Apply YTM and MTD filter to the Query Calculating "Total Sales" Amt
Hi,
I got the requirement to calculate "Total Sales" amount in following format,
1. Calculate Total Sales YTM per Country
2. Calculate Total Sales MTD per Country
I am done with Queries to get Country wise Total Sales amount but stuck at the point, how to apply YTM (Year to Month) and MTD (Month to Date) filter. Can anyone have idea about how to apply YTM and MTD filter to query??
Regards,
PriyankaHi,
I got the requirement to calculate "Total Sales" amount in following format,
1. Calculate Total Sales YTM per Country
2. Calculate Total Sales MTD per Country
I am done with Queries to get Country wise Total Sales amount but stuck at the point, how to apply YTM (Year to Month) and MTD (Month to Date) filter. Can anyone have idea about how to apply YTM and MTD filter to query??
Regards,
Priyanka -
Hi Experts..
I need a query to find the total items sold in a particular period for an particular item.
Pls help me in finding the query.
Regards,
Vamsi.
Edited by: Parimis on Jan 20, 2010 5:10 AMHi Vamsi,
Check the thread,
Help With Monthly Sales Query
Regards,
Madhan. -
SEM BPS - Planning function to distribute total value over months
Hello,
We use SEM BPS. In fact we use the integration of SEM BPS in the CRM opportunity component as opportunity planning.
Now we want to distribute the total value of certain key figures over the months. Either equal distribution or increasing distribution like 1% increase every month. What would be the best way to do that with a planning function?
We need to take into account that the number of months depends on the start and end date of the transaction (opportunity).
Best regards,
ThomasHi Thomas,
I would probably create a fox formula, do a foreach in selection loop over the months and distribute the values within that formula.
If you want to use a standard distribution function, you need to create the reference data somewhere before, which could be a bit difficult if the timeframe changes according to user selections.
regards
Cornelia -
How do I total expenses per month
I am using the check register template in numbers. I added a table to calculate a running total of expenses per category per month. I can get the table to keep a running total of expenses per category, but have not been able to add the per month value. How do I add that part into my formula. Specifically, my formula so far is =SUMIF(Transactions :: $Category,A2,Transactions :: Amount). Now all I need is to add the month value so I can see how much I am spending per month per category.
Transactions
Beginning Balance
$126.37
Type
Date
Description
Category
Amount
Balance
Debit
3/19/12
Gas at Shell
Bills
$ (50.54)
$ 75.83
Debit Card
3/20/12
Starbucks
Starbucks
$ (1.79)
$ 74.04
Debit Card
3/21/12
Freebirds Austin
Food
$ (9.72)
$ 64.32
Debit Card
3/23/12
Smokey Mo’s
Food
$ (7.00)
$ 57.32
Deposit
3/26/12
Deposit
Deposit
$ 100.00
$ 1,444.57
Debit Card
Bills
$ 1,444.57
DEP
Bills
$ 1,444.57
DEP
Bills
$ 1,444.57
Debit Card
Bills
$ 1,444.57
105
Bills
$ 1,444.57
DEP
Bills
$ 1,444.57
Debit Card
Bills
$ 1,444.57
Bills
$ 1,444.57
Here is an example of the checking register table I am building
Category
Amount
Home
$ 0.00
Food
$ (16.72)
Bills
$ (50.54)
Credit Card
$ 0.00
Entertainment
$ 0.00
Starbucks
$ (1.79)
Total
$ (69.05)
And here is an example of the table for "March" that I am building. But, I only want March expenses to add in this table. Once April comes around, I want a new table to show expenses per category for that month.
I am new to this community, to have patience please. -
Hello People,
Our problem it's related about, a Query OLAP, we put the Period Gen 4, as rows:
Jan
Feb
The table reflect the order in the outline, but when we add Total, the order is alphabetic, it's any workarround, to disable this automatic order?
Thanks!You have to check "Sort order" in the measure's properties
-
Hello,
Using Oracle 11g R2. I'm trying to present data in the following format. I've come up with the query below, but I don't think it's right.
COL1
COL2
COL3
NVL(COL4,SUM(COL4))
NVL(COL5,SUM(COL5))
NVL(COL4-COL5,SUM(COL4-COL5))
1
10
10/29/2013 12:04:02
40
50
-10
1
20
10/30/2013 12:04:21
80
20
60
1
30
10/31/2013 12:04:38
25
60
-35
total 1
145
130
15
2
40
11/01/2013 12:05:03
90
10
80
2
50
11/02/2013 12:05:41
85
50
35
2
175
60
115
total 2
320
190
130
grant total
465
320
145
create table testrollupRh (col1 number, col2 number, col3 date, col4 number, col5 number)
insert into testrolluprh values (1, 10, sysdate - 10, 40, 50)
insert into testrolluprh values (1, 20, sysdate - 9, 80, 20)
insert into testrolluprh values (1, 30, sysdate - 8, 25, 60)
insert into testrolluprh values (2, 40, sysdate - 7, 90, 10)
insert into testrolluprh values (2, 50, sysdate - 6, 85, 50)
select col1,
col2,
col3,
NVL(col4, SUM(col4)),
NVL(col5, SUM(col5)),
NVL(col4 - col5, SUM(col4 - col5))
from testrolluprh
where col1 is not null
and col2 is not null
and col3 is not null
and col4 is not null
and col5 is not null
group by rollup ((col1), (col1, col2, col3, col4, col5))
Any help is appreciated.Hi,
I don't see any problems with your code.
You should have an ORDER BY clause, of course. Almost all queries need an ORDER BY clause, but that's often omitted in this forum.
If you want to put labels, such as 'Total 1' and 'Grand Total' on the super-aggregate rows, you can use CASE and GROUPING, like this:
SELECT CASE
WHEN GROUPING (col2) = 0 THEN TO_CHAR (col1)
WHEN GROUPING (col1) = 0 THEN ' Total ' || col1
ELSE ' Grand Total'
END AS out1,
col2,
col3,
NVL (col4, SUM (col4)) AS out4,
NVL (col5, SUM (col5)) AS out5,
NVL (col4 - col5, SUM (col4 - col5)) AS out6
FROM testrolluprh
WHERE col1 IS NOT NULL
AND col2 IS NOT NULL
AND col3 IS NOT NULL
AND col4 IS NOT NULL
AND col5 IS NOT NULL
GROUP BY ROLLUP ( (col1)
, (col1, col2, col3, col4, col5)
ORDER BY col1, col3
Output:
OUT1 COL2 COL3 OUT4 OUT5 OUT6
1 10 29-Oct-2013 40 50 -10
1 20 30-Oct-2013 80 20 60
1 30 31-Oct-2013 25 60 -35
Total 1 145 130 15
2 40 01-Nov-2013 90 10 80
2 50 02-Nov-2013 85 50 35
Total 2 175 60 115
Grand Total 320 190 130 -
Using Calendar Year Month in query designer to populate a Month Structure
Hi
Is it possible to create a query that has a standard structure of Month Columns (Jan-Dec) with each month column populated by the correct 0CALMONTH (similar infoobject) value? I would also like to be able to filter this by the correct year selected since this will be a filter value.
Thanks for any help on this.Hi,
I would also like to be able to filter this by the correct year selected since this will be a filter value.
Yes. With the structure it is possible. But user input 0fiscalyear variable should be there to get the correct year data.
Hope it helps
Maybe you are looking for
-
Toolbox in Solaris management console
I installed Solaris management console 2.0 and when I try to open it, it asks me for a toolbox. What kind of file is a toolbox? Could anybody tell me how can i install a toolbox? Thanks
-
TS4002 how do you save email attachments on the ipad?
how do you save email attachments on the ipad? particularly ebooks sent via email
-
Hello! How I can be on the same page with the same table insert and update operations using 2 different forms (single form and tabular form) I have little knowledge of Apex, but I know PLSQL Thanks Ginger Ecuador
-
Make BP Contact Sap GUI fields Available in Web UI
Good day, I would like to make two fields available in the WebUI that are displayed in the SAP GUI in transaction BP The two fields exist in the BP - Contact When accessing txn BP, select a customer, select Relationships, double click "Has contact Pe
-
Restrict GI Qty as per BOM/Reservation
Dear Experts, Please guide me to address the following issue: As per Standard SAP, I can do GI (MB1A - 261 Mvt) for any quantity irrespective of reservation quantity (calculated as per BOM ratio). If the FG to HALB ratio is 1:1 and the production ord