Calculating count during previous months
I am working on a report where we need to track the number of tickets that were open at the end of previous months. I have calculated those tickets that were closed in the same month by comparing the month of the ticket's creation date with that of the ticket's close date using a CASE if:
CASE WHEN MONTH(ticket_fact.Modified) = Month(ticket_fact.Created) THEN 0 ELSE 1 END
How do I get just the count of all the tickets for this. I have results in a table but now each row shows a 0 or 1 and Pivot table does not seem to work as well.
If I use Status then I get the status that the ticket is currently in.
Thank you so much.
OK, based on what your are asking and what you have done, I have to ask if what you are trying to do is what you really want to track. For one thing, your approach only works "this year." Once the new year comes, using the MONTH function will get you the counts of both "this year" and "last year." So counting only using the "months" of the dates is not correct. You would need the YEAR function as well.
Second, if you want to know if tickets are being closed in a reasonable amount of time, then you don't want to track just tickets that "opened and closed in the same month." Why? Because what if a ticket opened two days before month end and closed three days later? Wouldn't that be pretty efficient? Yet your report won't track that since the created and closed dates are in different months.
What I would suggest as a better report is to track tickets that close within certain breakpoints in time, regardless of what day of the month it opened, for example, how many tickets were closed within 30 days? How many were closed in 60 days? etc. This report would give you a better analysis than tickets opened and closed in one month.
You would need to categorize your tickets with a CASE statement similar to the following:
CASE WHEN TIMESTAMPDIFF(SQL_TSI_DAY, ticket_fact.Created, ticket_fact.Modified) < 30 THEN 'Less than 30 Days' ELSE CASE WHEN TIMESTAMPDIFF(SQL_TSI_DAY, ticket_fact.Created, ticket_fact.Modified) < 61 THEN '30 - 60 Days'...
This is what you should count.
Similar Messages
-
Calculating receipts from previous month based on the sales of current mont
Hi Gurus,
I have a requirement where i need to display sales for a quarter and need to display receipts from the previous quarter. For example consider that i am displaying sales from week1-Aug to Week4-October, I need to display receipts ( R_Net_RCPTS) from Week1-july to Week4-September. In that way If i select Wk1-Aug for sales it should display Wk1-july receipts. i need to do this in Webi by creating appropriate variables.
I have got prompts on year and Fiscal Week
I have given year as 2011 and The "08: Fiscal Week From:" as "Wk1-Aug" to "08: Fiscal Week To:" as "Wk4-Oct"
I HAVE GONE THROUGH ALMOST ALL RELATED THREADS, BUT COULDN'T FIND ANY SOLUTION. ITS REALLY URGENT. PLEASE HELP ME AND I WILL FOR SURE GIFT POINTS.HI
Your explanation is not clear whether u want to display current quarter data or you would like to see only previous month data ?
Which dimension you are taking for week ? how data would be like ?
Edited by: K.sunil on Nov 21, 2011 9:14 AM -
Hello,
We need some help with an SSAS MDX query based on date logic. One of the problems is that I don't have access to the Cube but have been given a query example with the logic needed for the calculation. Here's the scenario;
The ETL process will run on the first Tuesday after the 15<sup>th</sup> of a given month. The Analysis Cube data queried should include the current year up to the end of the previous month. For example, on May 19<sup>th</sup>
(the first Tuesday on or after the 15th) the query should include data from January 1<sup>st</sup> through April 30<sup>th</sup>.
The 15<sup>th</sup> of the month is not part of the query, it is a factor in when the query is run. The query will always be in terms of complete months.
SELECT
NON EMPTY { [Measures].[Revenue Amount],
[Measures].[Utilization],
[Measures].[AVG Revenue Rate],
[Measures].[Actual Hours] }
ON
COLUMNS,
NON EMPTY { ([dimConsultant].[User Id TT].[User Id TT].ALLMEMBERS * [dimConsultant].[Full Name].[Full Name].ALLMEMBERS * [dimConsultant].[Employee
Type].[Employee Type].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,
MEMBER_UNIQUE_NAME
ON
ROWS
FROM
( SELECT
( { [dimDate].[Week Date].[1/4/2015], [dimDate].[Week Date].[1/11/2015], [dimDate].[Week Date].[1/18/2015], [dimDate].[Week Date].[1/25/2015], [dimDate].[Week Date].[2/1/2015] } )
ON
COLUMNS
FROM
( SELECT
( { [dimIsBillable].[Is Billable].&[True] } )
ON
COLUMNS
FROM
[SSASRBA]
WHERE
( [dimIsBillable].[Is Billable].&[True], [dimDate].[Week Date].CurrentMember ) CELL PROPERTIES VALUE,
BACK_COLOR,
FORE_COLOR,
FORMATTED_VALUE,
FORMAT_STRING,
FONT_NAME,
FONT_SIZE,
FONT_FLAGSHi Hans,
Thank you for your question.
I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.
Thank you for your understanding and support.
Regards,
Simon Hou
TechNet Community Support -
Previous Month, YTD, PreviousYTD counts in one report with charts
Hello to all users,
I am new to my current job and also to Crystal Reports. I was given the task of creating a sales summary report that has each salesman and their department and 3 different count fields of sales completed ( based on different date ranges). The 3 count fields need to be for the previous full month, YTD(current year) and then YTD ( previous year). We are running Crystal Reports 2008.
I tried using subreports but that seemed to throw off the overall size of the report. I also tried creating a formula field that had a count as well as a date filter for each field, but that threw and error of a boolean and numeric in the same field.
Could anyone out there tell me the best way to accomplish this report? Thanks in advance for any help or suggestions.This is going to be difficult, if not impossible to do with tables in Crystal. Do you know how to write SQL? The most efficient way to do this is going to be to write a command (SQL query). You can do this two ways:
1. Write a separate command for Previous Month, YTD, and Previous YTD, each of which does the counts for that time period and then join them together based on a field that identifies the sales person. However, if there are lots of sales people, this will be slow because Crystal will have to pull the results of all three queries into memory in order to join them together.
2. The best way is going to be to write a single query that pulls all of the data for your report.
-Dell -
Calculating previous month and year of the previous month
Hi frenz,
Can anybody know FM to calculate the previous month and year of the previous month.
are there any standard FMs existed to achieve this?
br,
anil.hi,
lv_period gives the month and year which is two months earlier now as we have specified lv_months as -2.
DATA: LV_PERIOD LIKE S001-SPMON,
LV_MONTHS(2) TYPE C VALUE '2-',
LV_DATUM LIKE SY-DATUM,
LV_NEWDT LIKE SY-DATUM,
P_SPMON LIKE S001-SPMON VALUE '200601'.
CONCATENATE P_SPMON '01' INTO LV_DATUM.
LV_PERIOD = P_SPMON+0(6).
CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
MONTHS = LV_MONTHS
OLDDATE = LV_DATUM
IMPORTING
NEWDATE = LV_NEWDT
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC = 0.
LV_PERIOD = LV_NEWDT+0(6).
ENDIF.
WRITE :/ LV_PERIOD.
Regards,
Sailaja. -
Getting data in a query on last date of all previous months
Dear Experts,
I need your help with a query.
I am trying to create a query which when run should pick the number of Open Sales Order on the last date of all the previous months from the start of company.
I could create the query for fetching the required data on last day of the previous month, say today is 25th June 2014, so my query only fetches data for May 31st 2014 but I need data for all previous month, May 31st 2014, April 30th 2014, March 31st 2014 & so on.
Please advise how to achieve this is SQL query.
Thanks & regards,
NitinHi,
Try this:
Select *
from(
SELECT T0.[DocNum] as #,t0.cardcode as C, t0.docdate
FROM ORDR T0
WHERE T0.[DocStatus] = 'o' and T0.[DocDate] = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-1,0)),10) OR T0.[DocDate] = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-2,0)),10) or T0.[DocDate] = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-3,0)),10) or T0.[DocDate] = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-4,0)),10) or T0.[DocDate] = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-5,0)),10) or T0.[DocDate] = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-6,0)),10) or T0.[DocDate] = CONVERT(VARCHAR(10), DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-7,0)),10)
group by t0.cardcode,docdate,T0.[DocNum]) S
pivot
(count(#) for c in([cvt01],[cvt02],[cvt03],[cvt04],[cvt05],[cvt06],[cvt07],[cvt08],[cvt12])) P
Note: Replace Cvt01,02...with your customer code.
Thanks & Regards,
Nagarajan -
How to show Increase/Decrease of Sales Amount compare to Previous Month.
Hi,
My users need to view the percentage decrease/increase of Sales $ compared to previous month, for each Month.
How can I create a Restricted Key Figures that show Sales $ Amount as of Previous Month (take note it is not just Previous Month from Current Month, but each Month's Previous Month). i.e
Nov 06 - Sales $ = 1000
N0v 06 - CKF_A - Variance Compare to Prev. Month: 100%
Dec 06 - Sales $ = 800
Dec 06 - CKF_A - Variance Compare to Prev. Month: -20%
(800-1000/1000)
Jan 06 - Sales $ = 1000
Jan 06 - CKF_A - Variance Compare to Prev. Month: 25%
(1000-800/800)
How can I create CKF_A and achieve similar result?
Most of the variables for 0CALMONTH or 0FISCPER seems pointing to one value only.
I don't want to create Restricted Key Figures for each and every month.
Please help.
Thanks,
Sean Yit.Sean,
You don't have to create RKFs for each and evry month. But you need to create just two RKFs.
Lets say that you want to display the months in rows and Sales in the first column and the variance in the second column. Just restrict Sales by the month characterstic with a user entry variable (range if it is more than one month the user wants to display), then in the next column create another RKF by restricting Sales with the same month characterstic. This time offset the first varaible by minus one (-1). In the properties of this RKF, select always hide option.
Now create a CKF (calculated key figure), by using the variance% formula option.
CKF = RKF2 "%" RKF1.
I hope this helps.. -
Last day of previous month, first day of current month
Hi,
Whats the best way to calculate the last date of the previous month, and the first day of the current month.
Thank you for your help.
Sumit.Here are FMs
SG_PS_GET_LAST_DAY_OF_MONTH FM calculating the last day of a month
FVOZ
RE_LAST_DAY_OF_MONTH
HRHCP00_TIME_HANDLING
HR_HCP_GET_LAST_DAY_OF_MONTH
HRVE_REPORTING
HRVE_LAST_DAY_OF_MONTH
RPDD HR-D: Payroll Germany
RP_LAST_DAY_OF_MONTHS HR-D: Determine last day of month
SLS0 PAW - Miscelaneous (MISC)
SLS_MISC_GET_LAST_DAY_OF_MONTH FM calculating the last day of a month
VVSRCH
LAST_DAY_OF_MONTHS
BWSO_DATE_GET_FIRST_WEEKDAY
CKSO
CK_F_GET_FIRST_DAY_OF_DATE
HRBEN00SPENDA
HR_BEN_SPENDA_FIRST_LAST_DAY
HRPB
HRPP_CCODE_GET_FIRSTDAY_PERIOD
HRVE_PAYROLL
HRVE_GET_FIRST_LAST_MONDAY
JBT6
ISB_GET_FIRST_DAY
KED2
RKE_GET_FIRST_DAY_IN_PERIOD
MCP2
MC_PERIOTAB_BT_FIRST_LASTDAY
MC_PERIO_GET_FIRST_AND_LASTDAY
Thanks
SK -
Display previous month value in report
Hi,
I have a requirement to display the previous month amounts on monthly basis. here is the example.
In the Cube I have data like this:
<b>Customer Month Amount</b>
C1 Jan 2004 $500
C1 Feb 2004 $600
C1 March 2004 $1000
I want to display in Report with another key figure to show the difference between current month and previous month. Report should look like:
<b>Customer Month Amount <i>Prev_Month_Amount <u>Diff</u>.</i></b>
C1 Jan 2004 $500 0 $500
C1 Feb 2004 $600 $500 $100
C1 Mar 2004 $1000 $600 $400
I have tried using restricted key figures.but it is showing the same amount in prev. moth amount colunm till feb 2004. anyone had similar req. please advise me.
Thanks in advance,
RamHi,
I can only think about a 2 structure approach with cell calculations.
This will result in a static report with 12 rows for each customer. Then you would need to use the new feature of zero supression, to hide those month where no data exists.
Heike -
Need to show Previous months data in report
Hi All,
I have a crystal report 2011 which shows monthly Cash data. It has 3 other columns like Previous 3 months cash data, previous 6 months cash data, Previous 12 months cash data in report.
My report also has two parameters- start date and end date. If I give Start date as 1/1/2012 and end date as 12/31/2013 (two years date range) then correct data comes in all columns and for 2013 year, correct data is coming for Previous 12 months column. But if I give only one month date range like start date as 1/1/2013 and end date as 01/31/2013, then it is not showing correct data for these 3 columns - Previous 3 months cash data, previous 6 months cash data, Previous 12 months cash data. Ideally as per requirement, it should calculate previous months data regardless of parameter values and put data in respective columns.
Any help/suggestion? Any trick which can help me to show correct data in all columns no matter what date range or months I am taking in parameters.
Is it mandatory to have previous 12 Months data in report to calculate column-Previous 12 months Cash data?
Thanks,
RemiHi Remi,
You can try like this:
I have given a some suggestions i.e You just take one parameter only because u can imagine 3 columns previous data display correctly i.e From Date
Month parameter is also a alternate option.
For Ex: Column1: From Date - 90 Days/3 Months - we get the three months previous data correctly etc.
Finally, create a stored procedure that returns the required columns and does all the calculations on the database side.
Follow abhilash suggestion as well.
Useful threads: Crystal Report Parameter Issue
Pull Last 6 months of data
Month to date data for Previous month
How to find current month, previous month Net Sales by means of formula?
Thanks,
DJ -
Display current and previous months records only
Hello gang,
My selection criteria looks like this:
not ({HRDEPBEN.PLAN_CODE} startswith ["C", "EAP", "HMIL", "V", "W"]) and
(month({hrdepben.Creation_date}) = month(currentdate)) and
{HRDEPBEN.PLAN_TYPE} = "HL"
I modified it to this in order to pull in previous month's data too:
{HRDEPBEN.PLAN_TYPE} = "HL" and
not ({HRDEPBEN.PLAN_CODE} startswith ["C", "EAP", "HMIL", "V", "W"]) and
(month({hrdepben.Creation_date}) = month(currentdate) or month ({hrdepben.Creation_Date})= month (currentdate)-1)
However, it's still pulls the same record count and only January records, not Decembers'.
Where am I going wrong?
ThanksLooks like you're reporting against Lawson? What database are you using?
There are a few issues with the record selection criteria as it's written:
1) Month(CurrentMonth) - 1 = 0 when the current month is January. That's why your not getting any records from December.
2) The monthly criteria won't be passed to the database for processing, which is a huge performance issue when you're reporting against a system like Lawson. You're basically telling the report to bring back all records that don't start with an array of values, irrespective of the date. Only after all the possible records are returned across the network will the extraneous records be filtered out on the client side. That's bad.
3) It's easy to use StartsWith or Like, but it's also pretty inefficient, since it forces a full table scan of the underlying table
Personally, I'd do one of two things in order to both fix the query and optimize it:
1) Write the underlying query in SQL as either a View or SQL Command object
or
2) Keep the current report, but make use of SQL Expression fields in order to optimize the query.
Here are some examples of SQL Expression fields against Oracle (PL/SQL) that could be useful:
/*{%PLANCODES}*/
/*This SQL Expression evaluates whether or not a Plan Code starts with the specified values*/
/*"HRDEPBEN"."PLAN_CODE" is selected directly from the Field Tree in the SQL Expression Editor*/
CASE
WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",1) IN ('C','V','W') THEN 'Y'
WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",3) = 'EAP' THEN 'Y'
WHEN SUBSTR("HRDEPBEN"."PLAN_CODE",4) = 'HMIL' THEN 'Y'
ELSE 'N'
END
/*{&CREATEDATEMONTH}*/
/*This SQL Expression returns the month of the Creation Date field*/
/*"HRDEPBEN"."CREATION_DATE" is selected directly from the Field Tree in the SQL Expression Editor*/
TO_NUMBER(TO_CHAR("HRDEPBEN"."CREATION_DATE",'mm'))
You could also create formula to return the Month value for last month and then use it in your record selection:
//{@LASTMONTH}
//This formula returns the Month value for Last Month
//IIF statements can be passed to the database for processing
IIF(Month(CurrentDate) = 1, 12, Month(CurrentDate) - 1)
With expressions and formulas like these in place (this code is Oracle and DB2 compatible, it would be different for T-SQL), you could then modify your record selection criteria to be something simpler, like this:
{HRDEPBEN.PLAN_TYPE} = "HL" and
{%PLANCODES} = 'N' and
{%CREATEDATEMONTH} IN {@LASTMONTH} TO MONTH(CURRENTDATE)// MONTH(CURRENTDATE) is passed to the DB
By laying the groundwork, you'll have a much more efficient report and, in the case of the @LastMonth, more accurate! Hope this helps!
p.s. a disclaimer on using SQL Expressions in this manner - it's not officially supported, although it's worked since Version 7 (when SQL Expressions were introduced) and there will be support for them in various 2011 versions. As such, they'll work for years. I use them all the time and they're fantastic for optimizing reports. -
MDX dimension formula in BPC to get the previous month failed with parents
Hi,
I'm working on a proof of concept and I need to create a formula with the following requirement:
Requirement
Account2 = Account2 (Previous Month) + Account 1
Accounts -Jan-Feb-Mar-Q1
Account1_____15___25___45____85
Account2_____15___40___85___140 <== OK
Now, I was thinking of applying this formula within Dimension, using MDX. Then I tried with these two examples, but they didn't work when rolling up to parents. I mean, the calculation for every month works fine, but, the Total Quarter or the Total Year are wrong:
Attempt 1:
Account2.Formula = (ParallelPeriod([Time].[Month], 1, [Time].CurrentMember), Account2) + Account1
Accounts -Jan-Feb-Mar-Q1
Account1_____15___25___45____85
Account2_____15___40___85____85 <== WRONG
Attempt 2:
Account2.Formula = (Account2,[Time].PrevMember) + Account1
Accounts -Jan-Feb-Mar-Q1
Account1_____15___25___45____85
Account2_____15___40___85____85 <== WRONG
How can I solve this ? Should I use Script logic instead of MDX to perform this calculation ?
Thanks!
Diego.DON'T use MDX script logic. It does not perform well under high data volumes or concurrency.
You're calculation can be done easy enough in SQL logic provided you scope the code correctly. Based on what you have given as requirements, the basic code would be something like:
*XDIM_ADDMEMBERSET TIME = PRIOR
*XDIM_ADDMEMBERSET ACCOUNT=A2
*WHEN ACCOUNT
*IS "A1"
*REC(EXPRESSION=%VALUE%+GET(ACCOUNT="A2",TIME=PRIOR),ACCOUNT=A2)
*ENDWHEN
*COMMIT
The first two lines make sure you have the prior period values for A2 in the scope of exection. Then when a record for A1 comes through, it would take that value and add it to A2's prior value for the exact same intersection of all other dimensions. You would separately have to deal with moving forward values of A2 if there were cases where you could have a value for A2 in a prior period but not have a value in A1 for the current period.
Edited by: James Sharrett on Apr 14, 2008 9:51 AM -
MDX YTD until previous month - problem for january
Hello,
I have a Time hierarchy YQMD
I want to make an MDX calculation that gives me the YTD until the previous month.
I did this with formula:
I first made a 'normal' ytd calculation resulting in 'MyMeasureYTD'
sum
(YTD([Time].[Years Quarters Months Weeks Days]),[Measures].[MyMeasure])
and then I use the following formula
ParallelPeriod([Time].[Years Quarters Months Weeks Days].[Months]),[Measures].[MyMeasureYTD]
this works fine for all months except for january: when the selected month is 'january' (of any year) , the result should be NULL, instead of the YTD until december of the previous year (which is what the formula above gives me).
I have tried with using an iif in the formula that checks on currentmember being the firstchild, but I don't seem to get the required result.
I would be very gratefull for your help!
kind regards
SylvieHi Sylvie,
Please refer to the MDX below with AdventureWorks sample:
with member [x]
as
iif([Date].[Calendar].currentmember is
Ancestor([Date].[Calendar].currentmember,3).firstchild.firstchild.firstchild,
"NULL",[Measures].[Internet Sales Amount])
select [x] on 0,
[Date].[Calendar].[Month].members on 1
from
[Adventure Works]
In my scenario, the hierarchy of Date Calendar is Year->Half Year->Quarter->Month->Day. So my Ancestor() function need to step back 3 levels. If you date hierarchy is Year->Quarter->Month->Day. It should be:
Ancestor
([Date].[Calendar].currentmember,2).firstchild.firstchild
If you have any question, please feel free to ask.
Regards,
Simon Hou
TechNet Community Support -
Previous month end based on prompted values
Hello All,
I need to create a SR report that shows:
Received in current month: count of Service requests recorded in current month selected. For instance if date prompt selection was March 2010 then count of SR recorded from Mar 1- 31,2010
Open Service Requests at month end Count of SRs where "Date Completion entered in system" is null as last day of month selected(eg March 31)
Carry over from Previous month: same as Open Service Request as month end less one month.( eg Feb 28)
I currently have a prompt which lets the end user choose the Month and Year they want to run the report for. I am getting the right values in my first two columns but my carry over is giving me problems. Any idea how I can write a formula for 'Carry over from Previous month'??
Any help is appreciated!
SoniaHi Max,
The carry over is causing problems. However, the formula for the month end chosen is
SUM(CASE WHEN CAST ("Service Request"."Closed Date and Time" AS DATE) IS NULL OR CAST ("Service Request"."Closed Date and Time" AS DATE) > TIMESTAMPADD (SQL_TSI_MONTH, 1, (TIMESTAMPADD (SQL_TSI_DAY, - (DAYOFMONTH(CAST ("- Service Request Custom Attributes".INDEXED_DATE_0 AS DATE))), CAST ("- Service Request Custom Attributes".INDEXED_DATE_0 AS DATE))))THEN 1 ELSE 0 END)
But when I use this formula for previous month (-1).. It does not work. It gives me zero.
Thanks!
Sonia -
Need help with SQL retrieval for previous month till current date
Hi ,
Need help generating statistics from previous month from date of enquiry till current date of enquiry.
and have to display it according to date.
Date of enquiry : 03/02/2012
Application Type| 01/01/2012 | 02/01/2012 | 03/01/2012 |...... | 31/01/2012 | 01/02/2012 | 02/02/2012 | 03/02/2012 |
sample1 20 30 40
sample 2 40 40 50
sample 3 50 30 30
Hope you guys can help me with this.
RegardsHi,
932472 wrote:
Scenario
1)If i run the query at 12 pm on 03/2/2012. the result i will have to display till the current day.
2)displaying the count of the application made based on the date.
Application type 01012012 | 02012012 | 03012012 | ..... 01022012| 02022012|03022012
sample 1 30 40 50 44 30
sample 2 35 45 55
sample 3 36 45 55Explain how you get those results from the sample data you posted.
It would help a lot if you posted the results in \ tags, as described in the forum FAQ. {message{id=9360002}
SELECT application_type as Application_type
, COUNT (CASE WHEN created_dt = sysdate-3 THEN 1 END) AS 01012012 (should be getting dynamically)
, COUNT (CASE WHEN created_dt = sysdate-4 THEN 1 END) AS 02022012
, COUNT (CASE WHEN created_dt = sysdate-5 THEN 1 END) AS 03022012
, COUNT (CASE WHEN created_dt = sysdate-6 THEN 1 END) AS 04022012
FROM table_1
GROUP BY application_type
ORDER BY application_typeThat's the bais idea.
You can simplify it a little by factoring out the date differences:WITH got_d AS
SELECT qty
, TRUNC ( dt
- ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
, -1
) AS d
FROM table1
WHERE dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
, -1
AND dt < TRUNC (SYSDATE) + 1
SELECT SUM (CASE WHEN d = 1 THEN qty END) AS day_1
, SUM (CASE WHEN d = 2 THEN qty END) AS day_2
, SUM (CASE WHEN d = 62 THEN qty END) AS day_62
FROM got_d
See the links I mentioned earlier for getting exactly the right number of columns, and dynamic column aliases.
Maybe you are looking for
-
I know this seems extremely trivial, but has anyone had difficulty in changing the color of lines and shapes in Keynote? I'm not a novice at this (I have extensive experience with Powerpoint), but this is making me a little crazy. I've followed the d
-
Saving Elements 9 Edited photos to IPhoto 11
I am fairly new to using IPhoto. Elements is old hat to me. When I edit a photo in Elements and save it to IPhoto it seems to get lost. I shoot in RAW, cntrl click and say open in external editor (Elements 9) and do my editing. Then I do a "save as"
-
Error when trying to download purchased items
Hello, when I am trying to download my purchased items, I get an error message "Unable to check for available downloads The itunes store is temporally unavailable. Please check again later." I can use the store however. When I ran itunes network diag
-
Error occures when try to download Download LiveCycle Enterprise Suite Update 1 trial version
when i am tring to dowanload LiveCycle Enterprise Suite Update 1 trial version from http://www.adobe.com/cfusion/tdrc/index.cfm?product=livecycle Akamai Download Manager - Error comes & i am not able to dowanload. on screen - File Name:JBoss_EFGJ_DVD
-
How to open URL iView in new window
HI, We are not able to open the URL iView, which is assigned to page, in new window. We set the property "Launch in New Window" to Launch in Separate Window but no use. Please let us know the solution Thanks