Select SQL statement - See all the value of the range of month of entry
Hi allI have a vision that is a union of other views
But the description of the view is as below
desc dashboard_monthly_view
Name Null Type
------------------------------ ---- ------------
MONTHS VARCHAR2(17)
NUM_DEPENDENT_IN_ASSESSMENT NUMBER
NUM_REFERRED_AODTC NUMBER
NUM_AT_DETERMINATION_HEARING NUMBER
NUM_ACCEPTED NUMBER
NUM_NOT_ACCEPTED NUMBER
NUM_EXITED_SUCCESS NUMBER
AVERAGE_DAY_TO_EXIST NUMBER
NUM_EXITED_UNSUCCESS NUMBER
AVERAGE_DAY_TO_EXIST_UNSUCCESS NUMBER
COURT_NAME VARCHAR2(9)
-current data in the viewMONTHS NUM_DEPENDENT_IN_ASSESSMENT NUM_REFERRED_AODTC NUM_AT_DETERMINATION_HEARING NUM_ACCEPTED NUM_NOT_ACCEPTED NUM_EXITED_SUCCESS AVERAGE_DAY_TO_EXIST NUM_EXITED_UNSUCCESS AVERAGE_DAY_TO_EXIST_UNSUCCESS COURT_NAME
----------------- --------------------------- ---------------------- ---------------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------------ ----------
AUG 2012 1 0 0 0 0 0 0 0 0 AAA
OCT 2012 8 1 3 1 1 1 44 1 4 AAA
SEP 2012 2 0 2 2 0 0 0 0 0 AAA
*UNDEFINED* 0 11 7 1 1 0 0 1 0 AAA
NOV 2012 0 0 0 0 0 0 0 1 54 BBB
OCT 2012 4 1 2 1 1 1 9 0 0 BBB
SEP 2012 1 0 0 0 0 1 14 0 0 BBB
*UNDEFINED* 0 5 4 1 0 0 0 1 0 BBB
AUG 2012 1 0 0 0 0 0 0 0 0 COMBINED
NOV 2012 0 0 0 0 0 0 0 1 54 COMBINED
OCT 2012 12 2 5 2 2 2 26.5 1 4 COMBINED
SEP 2012 3 0 2 2 0 1 14 0 0 COMBINED
*UNDEFINED* 0 16 11 2 1 0 0 2 0 COMBINED
13 rows selected
-My select query is DEFINE startmonth = "Aug 2012";
DEFINE endmonth = "Nov 2012";
with all_months as
( select to_char(which_month, 'MON YYYY') month from
(select
add_months(to_date('&startmonth','MON YYYY'), rownum-1) which_month
from
all_objects
where
rownum <= months_between(to_date(NVL('&endmonth', '&startmonth'),'MON YYYY'), add_months(to_date('&startmonth','MON YYYY'), -1))
order by
which_month )
)
select nvl(months, '**ALL**') AS "MONTHS", TO_DATE(MONTHS, 'MON YYYY') AS MONTH_SORT
, sum(num_dependent_in_assessment) AS num_dependent_in_assessment
, sum(num_referred_aodtc) AS num_referred_aodtc
, sum(num_at_determination_hearing) as num_at_determination_hearing
, sum(num_accepted) AS num_accepted
, sum (num_not_accepted) AS num_not_accepted
, sum(num_exited_success) as num_exited_success
, sum(average_day_to_exist) as average_day_to_exist
, sum(num_exited_unsuccess) as num_exited_unsuccess
, sum (average_day_to_exist_unsuccess) as average_day_to_exist_unsuccess
from
DASHBOARD_MONTHLY_VIEW right outer join all_months
on DASHBOARD_MONTHLY_VIEW.months = all_months.month
--where months in (select month from all_months)
and upper(court_name) like 'AAA'
group by (months)
order by month_sort
- And the result isMONTHS MONTH_SORT NUM_DEPENDENT_IN_ASSESSMENT NUM_REFERRED_AODTC NUM_AT_DETERMINATION_HEARING NUM_ACCEPTED NUM_NOT_ACCEPTED NUM_EXITED_SUCCESS AVERAGE_DAY_TO_EXIST NUM_EXITED_UNSUCCESS AVERAGE_DAY_TO_EXIST_UNSUCCESS
----------------- ------------------------- --------------------------- ---------------------- ---------------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------------
AUG 2012 01/08/12 1 0 0 0 0 0 0 0 0
SEP 2012 01/09/12 2 0 2 2 0 0 0 0 0
OCT 2012 01/10/12 8 1 3 1 1 1 44 1 4
**ALL**
-The requirement of results I have to produce isMONTHS MONTH_SORT NUM_DEPENDENT_IN_ASSESSMENT NUM_REFERRED_AODTC NUM_AT_DETERMINATION_HEARING NUM_ACCEPTED NUM_NOT_ACCEPTED NUM_EXITED_SUCCESS AVERAGE_DAY_TO_EXIST NUM_EXITED_UNSUCCESS AVERAGE_DAY_TO_EXIST_UNSUCCESS
----------------- ------------------------- --------------------------- ---------------------- ---------------------------- ---------------------- ---------------------- ---------------------- ---------------------- ---------------------- ------------------------------
AUG 2012 01/08/12 1 0 0 0 0 0 0 0 0
SEP 2012 01/09/12 2 0 2 2 0 0 0 0 0
OCT 2012 01/10/12 8 1 3 1 1 1 44 1 4
NOV 2012 01/11/12 0 0 0 0 0 0 0 0 0
**ALL**
On the tota (* EVERYTHING *) l, I tried to use the rollup but he total average too, which is not correct. I think the reason because he cannot read the form that was used to calculate the column.How can I fix this, should I create, select another below one, with the sum of each column and the average for the other columns.
Also, the business analyst want to show all the months between the start and end of the month.
I used the right outer join, but apparently does not produce the right result.
If anyone of you have any ideas, please advise.
We use Oracle 11 g, it is a select statement for an Oracle APEX report.
The APEX version is 4.0.2. I'm a junior developer of the APEX and I still have to learn a lot about SQL Oracle analytic function.
Thank you very much in advance.
Ann
Hi, Ann.
Ann586341 wrote:
... I created a table to contain a simplified version of this view
Thank you. It is much easier to work with.
... My query is
DEFINE startmonth = "Aug 2012"; DEFINE endmonth = "Nov 2012"; with all_months as ( select to_char(which_month, 'MON YYYY') month from (select add_months(to_date('&startmonth','MON YYYY'), rownum-1) which_month from all_objects where rownum <= months_between(to_date(NVL('&endmonth', '&startmonth'),'MON YYYY'), add_months(to_date('&startmonth','MON YYYY'), -1)) order by which_month ) ) , tbl_dashboard_active as ( select * from tbl_dashboard_monthly where months != '**UNDEFINED**' ) select tbl.months AS "MONTHS" --, TO_DATE(tbl.MONTHS, 'MON YYYY') AS MONTH_SORT , tbl.num_hearing , tbl.num_exited_success , tbl.avg_day_success_exist , tbl.num_exited_unsuccess , tbl.avg_day_unsuccess_exist from tbl_dashboard_active tbl right outer join all_months am on tbl.months = am.month and upper(tbl.court_name) like 'BBB' UNION ALL select 'ALL' AS "TOTAL" , SUM(tbl.num_hearing) , SUM(tbl.num_exited_success) , round(AVG(tbl.avg_day_success_exist),2) , SUM(tbl.num_exited_unsuccess) , round(AVG(tbl.avg_day_unsuccess_exist),2) --order by to_date(am.month,'MON YYYY') from tbl_dashboard_monthly tbl right outer join all_months am on tbl.months = am.month and upper(tbl.court_name) like 'BBB'
- And the result I got
MONTHS NUM_HEARING NUM_EXITED_SUCCESS AVG_DAY_SUCCESS_EXIST NUM_EXITED_UNSUCCESS AVG_DAY_UNSUCCESS_EXIST ----------------- ----------- ------------------ --------------------- -------------------- ----------------------- AUG 2012 1 0 0 0 0 OCT 2012 1 0 0 2 35 SEP 2012 1 0 0 0 0 ALL 3 0 0 2 11.67
I don't know why even I already filter all lines that the month is undefined, I still have a blank line in the result set.
This is the line for November. You do an outer join, in order to ensure that each value of am.month is displayed, even if it does not match what anyone in tbl. When it does not match anything, then all the columns tbl is supposed to provide will be NULL. You decide to view tbl. months, which is one of the following columns will be NULL. You should display mod. monmth instead.
But if I run for handset Court, I don't see this problem. The reason is that the Court combined have given for all four months?
When you say "on behalf of the combined Court", do you mean the unconditional "upper (tbl.court_name) as"BBB "?
If Yes, that would explain it.
Also is it possible to list all the months between the start and end month assuring the user even if the statistics are 0.
Once again, in the case of lines that are present, even if they do not have the status of outer join, all of these columns will be NULL. Use NVL to map these nulls to 0.
and how to sort the month
GROUP OF two expressions, which depend on each other: one for sorting and the other for display.
For the sort expression, you can use months as a DATE. (It seems that you have tried this, but commented on the ORDER BY clause in your query is before the FROM clause.) The ORDER BY clause is always at the end of the query, after the FROM clause.)
Another expression of sorting is the number you used to generate the first month. That's what I used below.
Here's a way to get the results you requested:
WITH got_months AS
(
SELECT TO_DATE ('&startmonth', 'Mon YYYY') AS startmonth_dt
, TO_DATE ( NVL ( '&endmonth'
, '&startmonth'
)
, 'Mon YYYY'
) AS endmonth_dt
FROM dual
)
, all_months AS
(
SELECT rownum AS month_num
, TO_CHAR ( ADD_MONTHS ( m.startmonth_dt
, ROWNUM - 1
)
, 'MON YYYY'
) AS months
FROM got_months m
CROSS JOIN all_objects
WHERE ROWNUM <= 1 + MONTHS_BETWEEN ( m.endmonth_dt
, m.startmonth_dt
)
)
SELECT NVL ( am.months
, 'All'
) AS months
, SUM (NVL (tbl.num_hearing, 0)) AS num_hearing
, SUM (NVL (tbl.num_exited_success, 0)) AS num_exited_success
, AVG (NVL (tbl.avg_day_success_exist, 0)) AS avg_day_success_exist
, SUM (NVL (tbl.num_exited_unsuccess, 0)) AS num_exited_unsuccess
, AVG (NVL (tbl.avg_day_unsuccess_exist, 0)) AS avg_day_unsuccess_exist
FROM all_months am
LEFT OUTER JOIN tbl_dashboard_monthly tbl ON am.months = tbl.months
AND UPPER (tbl.court_name) = 'BBB'
GROUP BY GROUPING SETS ( (am.month_num, am.months)
, ()
)
ORDER BY am.month_num
;
Again, I used two GROUP BY expressions: one for sorting, the other for display. These depend on each other, that is, given one, you could derive from each other, and it is not sensible to dependent ROLLUP GROUP BY expressions like that, so I used GROUPING SETS ROLLUP instead, so it would be only 1 rank of great aggregate (in other words, 'all').
Output:
` AVG_ AVG_
NUM_ DAY_ NUM_ DAY_
NUM_ EXITED_ SUCCESS EXITED_ UNSUCCESS
MONTHS HEARING SUCCESS _EXIST UNSUCCESS _EXIST
--------- ------- ------- ---------- --------- ----------
AUG 2012 1 0 0 0 0
SEP 2012 1 0 0 0 0
OCT 2012 1 0 0 2 35
NOV 2012 0 0 0 0 0
All 3 0 0 2 8.75
Tags: Database
Similar Questions
-
How to see all the sql on sql statements commands under 'history' link
Hi all
How to see the history of sql on sql commands tab.
I want to see all the sql statements.
Where we set if we need to store more sql statements in history.
We use Apex3.2 and 10g (EE) database.
Thank you
NrIs there a limitation to the Apex 3.2, there are only 200 files...
Not sure about this, as I said earlier, the report is configured to display a maximum of 1,000 records, perhaps during the in-house data entry in the apex, she could to check something. In any case, all these are an internal feature and is not supposed to be "messed" with and could lead to no support.
Your alternative uses the same method I proposed, and you can query manually (after granting dba) table of APEX_040000.wwv_flow_sw_sql_cmds or even do a report in your application with a csv export.
-
Is there a place I can see all the Apple pay transactions outside bank statements
ask yourself, is there a list of movements of Apple pays somewhere in my wallet account or Apple.
Since then, I have two phones hooked up to 3 different cards it becomes cumbersome to look thorough all the instructions to find out according to bank statements
Is there a place I can see all the Apple pay transactions outside bank statements
N °
TT2
-
The Drobo contains all our movies (or downloaded from iTunes is torn from the dvdd we bought in the past). I can see and manage these fines to the iMac that lives in the study. However, we find the restrictive apple tv interface to browse movies when you want to decide what we're going to watch. I wanted to be able to use my mac to air in the TV room and navigate using the iTunes interface (where you can see all the images that were previously on the front of the dvd) to help decide what to watch. I put the library in iTunes on the mac air to point to the drobo but all it shows me these movies that have been downloaded from iTunes. How can I change this so that I can browse all movies?
Sorted!
Necessary to create the share with the local network in the preferences of iTunes on the iMac. Then the Mac Air noted that there is now a drop-down menu at the top left of the screen (same level as the movie, tv, buttons etc. It has two options for me, one for my computer and one for the library, I shared the iMac. When I select this library, I can now see all film, television and music content stored on the Drobo.
-
Original title: Windows - month view calendar
How to see all the appointment information, that I entered in the display "months"? It shows only the first two words entered.
Hi LouiseLUPI,
1. were you able to view before full nomination information?
2. you remember to make changes to the computer recently?
You can try the following steps and check:
a. open Windows Calendar, and then click display.
b. in the view, select day and check if it helps.
For more information, see the link:
Customize Windows Calendar
http://Windows.Microsoft.com/en-us/Windows-Vista/customize-Windows-Calendar
Hope this information is helpful
-
As I set up my computer with Windows 7 Professional and XP virtual machine, I could see all the readers, W7 and the virtual machine on the same screen. I can't do now for some reason any. All I can understand what is is past is that I got a page long list of automatic updates of W7 and some XP updates and as far as I know, the current page of readers has disappeared since then. I need this feature if I can transfer files between W7 and XP because some of my programs are in one program of windows. I have nothing special when I installed XP to achieve this functionality, so I really don't understand what it controls. How can I get that back?
I have solved my problem by trying everything that moves. Here are my steps:
-Open Virtual PC and minimize it
-In the Windows 7 machine, click Start click all programs
-Select Windows Virtual PC
-Select Windows Virtual PC (in the drop-down list)
-When the window opens, right-click on Windows XP Mode
-Select share >
-Select the homegroup (read/write)-Minimized open Virtual PC
-Select my computer
Windows 7 disks will be under otherI hope this works for you also. As I said, it worked like this until I had a huge list of automatic updates of Windows 7 and XP more some updates. Apparently, one of them cut something.
Even a blind squirrel finds an Acorn once in a while!
-
See all THE files that links to a file?
I wonder if it is possible to choose a file (say "test_photo.jpg" image) and ALL the other files that the image is linked to see. If ideally I would choose "test_photo.jpg" and somewhere, he would show me that "test_photo.jpg" is used as a link 'brochure_layout.indd', 'business_card.ai' and 'postcard.indd'.
This could be in Adobe Bridge, in the meta data in another program, anything really. I just want to know if this information is stored somewhere on the computer?
I know that the bridge can select an InDesign file & tell you what are the links; but it's not the information I'm looking for; again, it is more for the image files to see ALL the different files that link to him.
Hope someone has an idea if it exists.
Thank you!
TIA
N °
-
The page won't scroll down to see all the content. How can I solve this problem?
My pages please scroll to see all the content. I don't want to scroll on home pages, comments, or contacts, but I want to scroll pages with thumbnails.
For example this page:
http://megancampagnolo.com/loves.html
How can I solve this problem?
Widget slideshow on the page seems to be pinned and pinned items are not considered part of the content of the scroll bar.
Then, select the slideshow in design widget and unpin it.
Thank you
Vinayak
-
iTunes doesn't see all the bool in iBooks
When the dressage to sync with my iPad pro, iTunes does not see all the ANDS PDF books in my library iBooks on my mac pro. After thinking that I'm the only one having this problem I also saw on Mac/iPad another user where only iBooks library books appear in iTunes when you attempt to synchronize. There must be a bug somewhere that Apple could not find year last of harassing them.
I went through the pain and torture to find books on the cloud and copy them into the computer, remove all plists associated with iBooks and reconstruction of the library (I have close to 2,000 books and PDF documents in the library). Everything works perfectly... for awhile... now, yesterday I added 14 PDF documents to the library and iTunes sees none of them. I renamed one of the collections and created a new collection for the PDF 14 new and renowned collection or display the new collection in iTunes or the fact that they synchronize when I told iTunes to synchronize the entire library... I suspect that some of the books were removed in fact the iPad from iTunes has lost track of some of the books he has seen previously. It's really frustrating because I don't want to use the books in the cloud, because they must be downloaded manually to the iPad or iPhone and with lots of books, I spent all my time clicking on this button of cloud and never anything read.
The response of the Apple support was to use iCloud, blah, blah, blah, because that's the way it is designed to be used which seems to me arrogant or stupid. And after struggling for an hour with a friend yesterday who had the same problem and use iCloud... same symptoms... a list of books and other non I see no difference.
Cela has anyone yet figured out?
Well, it isn't a problem for real, but I removed two files and a .plist to the library. A revived the iBooks and low and here's all appear again and iTunes sees everything, including two new collections and 150 new books and pdf. I have used this twice before and was actually hope that there could be a real problem now.
-
How can I see all the ios on my computer applications, as well as on the iPhone?
There was once an option in iTunes to see all the applications that I had purchased or downloaded, including those which are not currently installed on my iPhone in a list on the left displays iPhone apps (Yosemite / iTunes 12.3.1).) Then I moved to a new iMac running El Capitan / iTunes 12.3.3. Now iTunes shows apps on my iPhone (a very poor screen but they are there), but it is more so the more complete list showing all applications stored on my iMac. They are always there in my iTunes library (in fact, I have 3 different libraries) to:
iTunes > iTunes Media > applications mobile but iTunes does not see them.
Can it be fixed or is it combination of El Capitan software / iTunes 12.3.3?
-
I used to be able to see all the cookies that had been installed, and now I can't.
I am irritated beyond belief. Why should you change a good thing and make stupid?
In the part of privacy options, I used to be able to see ALL the cookies that have been installed in a window, and I could choose those to whom I want to delete. I guess it was just too much control to give to us, if you had to remove this feature, right?
I would go back to a previous version of Firefox. I'm sick and tired of your stupid updates that screw things for everyone.
How can I revert to a previous version?- IF you use the parameter "Remember history" (as described in this article-> story to remember), click Delete the Cookies to view all cookies
- IF you use the parameter "use custom settings for history" (as described in this article-> use the custom settings for history), click View the Cookies to view all cookies
Check and tell if its working.
-
Why I can see all the photos on FaceBook with Explorer and I canoe see some using then?
When I browse my Facebook using Firefox, I can't see some of the pictures. But when I use Internet EXPLORER I can see all the photos on my FaceBook page. Why is this happening? Magda.
You are welcome
-
CPU goes to 100% svchost State takes all the resources on the Qosmio F10
CPU goes to 100% svchost State takes all the resources. Norton can not find any illegal software. Have tried to list the processes (run... etc.). I get a long list, don't know what to do about this. Anyone out there have some help?
Hey Buddy
The same problem here. :( A universal solution is unknown to me but what I do is from the Task Manager. When svchost shows more than 90% of its use I simply stop this stupid process. After having done that, I can use my laptop without any problem and it will not happen again.
After restarting the laptop, the same thing happens again. I checked some other forums but never found no reasonable explanation how manage this stupid question.
If someone knows more please let us know.
-
LookoutDirect 4.5
(2) is there a place that I see all the logics without seeking the properties of each object?
It seems that the lookout 4.5 is not browser connection. We have added this tool to view the connections at the belvedere 5.x.
-
I want to see all the devices that are connected to my router
I have a router E1200 and it is very good, however I have noticed that there are 12 devices connected to my router so infact it should be only 4 devices. I would like to see all the devices that are connected and disconnect those who do not belong to HELP!
You use software to see all the devices that are supposed to be connected to your router? You can reset and start over with your router. Make sure you have security enabled on it as WPA Personal. You can try a DHCP reservation so to ensure that devices that will have access to your router are those you have included on the list.
Maybe you are looking for
-
I'm trying to disable audibles on the first watch of gen 3 ongoing watch OS. I want just the haptic alerts. How can I do? I've not had much luck finding an answer.
-
iCloud backup does not include recent emails
I backed up my iPhone 6 to iCloud for the first time, but the most recent emails are from 2014. Where are the rest of my emails?
-
Skype won't let me log in again
So I had this problem a long time ago where Skype wouldn't let me log on. Basically, when I clicked the box to write my name/pass in nothing happened there. So I tried the rename "login" to "login1" and create a shortcut on the desktop of solution an
-
remove table icon don't develop
Hello Someone has problem with the icon "delete table" which grow to accept more clues? Context-sensitive help, it shows the icon to delete array as extensible, but it won't work. Thank you ATD
-
Hello I got a recommended set the HP Support Assistant program to update update for HP Notebook System BIOS (AMD processors). I installed the update to the BIOS but the HP Support Assistant still says I need to run the BIOS update. So I ended that