Count and range columns based on amount of time
I'm doing SSRS and I have a table that has two different datetime columns called TranTime and AppTime.
What I want to do is take the difference in time between those tables and do some counting based on that difference calculated. For example, if the difference between the two dates is less than 5 minutes, then I want to have a column that counts
the number of rows that have less than 5 minutes. I want to do the same thing to count the number of rows that are greater than or equal to 5 minutes, but less than 10 minutes. And have another column that is greater than or equal to10 minutes,
but less than 15. And then have a final row that counts all of the rest of the rows that are 15 minutes or greater. I think I have to use some sort of case statement but I keep getting error messages. Any thoughts...? Thanks in advance
Hi jrcowles94,
According to your description, you have two datetime type columns in your report. Now you want to count the number of records based on the difference of these two data fields. Right?
In this scenario, we can use DateDiff function to get the difference between two datetime. Then we use IIF function to make judgement inside of aggregation fucntion, also specify the scope for the aggregation function. We have tested your case in our local
environment. Please try the expressions below:
<5: =sum(IIF(DateDiff(DateInterval.Minute,Fields!TranDate.Value,Fields!AppDate.Value)<5,1,0),"DataSet1")
5-10: =sum(IIF(DateDiff(DateInterval.Minute,Fields!TranDate.Value,Fields!AppDate.Value)>5 and DateDiff(DateInterval.Minute,Fields!TranDate.Value,Fields!AppDate.Value)<10,1,0),"DataSet1")
>10: =sum(IIF(DateDiff(DateInterval.Minute,Fields!TranDate.Value,Fields!AppDate.Value)>10,1,0),"DataSet1")
The result looks like below:
If you have any question, please feel free to ask.
Best Regards,
Simon Hou
Similar Messages
-
Level Based Measure and a column based on that
Hello All,
I need suggestions to implement the following requirement.
1. No of orders stored in a fact table at day level
2. No. of orders at month level should be calculated
3. Depending on the count, each month would be assigned to a bucket.
0-10 orders -> B1
11-100 orders -> B2
> 100 orders -> B3
What I did in RPD
1. fact joined to time dimension
2. created a logical column: ORDER_COUNT: count(distinct order_number) iand set the level = month
3. created a logical column: BUCKET: using the output of above logical column and CASE statement to implement the bucket rule.
Now, when I run a report like this:
Year; ORDER_COUNT; BUCKET
Returns me 12 rows. Understood because ORDER_COUNT is a month level measure
E.g.
2011 5 B1
2011 5 B1
2011 15 B2
2011 15 B2
2011 5 B1
2011 5 B1
2011 15 B2
2011 15 B2
2011 5 B1
2011 5 B1
2011 15 B2
2011 15 B2
But as soon as I pull the BUCKET column as column heading in pivot table, it returns me only the 1st month row and changes the "BUCKET" value to B3.
Looks like, it recalculates the bucket and sums up all 12 months orders and then applies the bucket rule.
Like this -
B3
2011 5
My expectation was something like this
B1 B2 B3
2011 30 90 0
where 30 is the sum of the order_counts of all B1 months, <m>
Ques:
1. Is there a way I can avoid the recalculation of bucket information when the granularity/dimensionality changes in the report
2. I read in the below link that if the grain of the report > grain of the level-based-measure then the output of the report is "not-deterministic"
Am I hitting that scenario?
[http://gerardnico.com/wiki/dat/obiee/measure_level_based]
Any suggestion would be highly appreciated.
I am using 11.1.1.6.2 version.
Thanks & Regards
MonikaHi ,
If I understand your requirement correctly , then you need currency Conversion.
you can refer this links.
http://consultingblogs.emc.com/christianwade/archive/2006/08/24/Currency-Conversion-in-Analysis-Services-2005.aspx
http://www.ssas-info.com/analysis-services-faq/27-mdx/244-how-change-currency-symbol-based-on-selected-currency-dimension-member
http://social.technet.microsoft.com/wiki/contents/articles/18672.currency-conversion-in-ssas-2012-multidimensional-tabular.aspx
May I know , You Require all this using MDX and SSRS Parameter ?
Thanks -
Song and Video downloading taking long amounts of time.
I have been trying to download a 5 minute music video, and the process has taken over an hour so far. I am wondering if there is any setting I could change, or something wrong on my PC that is causing this.
I'm using a cable connection from a wireless router, and I'm getting 11.00 Mbps. the strange thing is, it's never done this before. Just yesterday, everything started downloading really slow.
-
iphone went dark. will not turn on. died at end of a call. tried the power/home holding option.. no good. had plenty of power. when plugged into computer
nothing changes... its not acknowledged by computer, iphone doesnt charge.. etc... appears completely deadIf a reset didn't work & you're sure the battery is charged, make an appointment at an Apple store.
-
Columns based on first/last aggregation rule not visible in Answers
Hi guru!
I don't understand my mistake!
1. "summ" column in fact table
2. Time dimension with TOTAL-YEAR-QUARTER-MONTH-DAY levels
3. set up for "summ" column last aggregation
4. and set checkbox (based on dimension): for Time dimension LAST, for others SUM
but in Answers this "summ" column is NULL.
why?Is it possible that the last selected value of the Time dimension has no data? For example, if you're displaying all possible days of 2008, and you haven't loaded Dec-31-2008 data yet, the "last" value selected (i.e. Dec-31-2008) would not yet have been loaded with data, so the LAST aggregation function would return a NULL.
Thought: Try the query using a filter on the Time dimension to select a time period that is already completely loaded with data, and let us know what happens there. -
Counting columns based on set criteria?
Hello gurus,
I've been trying for the past hour to count the number of columns that have a certain condition met, that is two check boxes are ticked.
For example:
I want to count the number of columns where both Apples & Oranges is TRUE.
I've tried combinations of SUMIF, COUNTIF, IF, & COLUMNS and really don't have a clue. Searching the web for Excel examples doesn't help and I can't find anything like this on this forum.
Any help would be much appreciated.
Regards,
Dr Paul MartinThe closest I've been is this:
=COUNT(AND(Table :: Apples,Table :: Oranges))
The AND function only generates one result (TRUE/FALSE) which I convert to a number (1/0) with the COUNT function.
The problem is that I can't count a range of columns that meet this criteria.... it will only give me one result not the total number of positive results.
What I need is something like this:
=COLUMNS(AND(Table :: Apples,Table :: Oranges))
Except that generates an error "COLUMNS requires a range but found a boolean instead". I guess I can't mix them up?
Regards,
Dr Paul Martin
Message was edited by: nitramluap -
Populate multiple rows and columns based off of a single cell
Does anyone know a way to populate multiple rows and columns based off of the input of a single cell. I'm trying to create a workout tracker that auto populates from a master list of workouts. Example, in A2 the user selects the workout from a drop down menu (St1, St2, St3, etc) and the workout is pulled from the master list and is populated into B2:C5.
I'm using =LOOKUP(A2,Master :: A2:A32,Master :: C2:C32) right now, but it's only drawing the top column. I'm looking for an edit for the formula (or completely new formula) that will place the info from the 1st column of the Master table into the 1st column of the Auto Tracker 1 table and then on down until the 4th column.
Here is a screen shot of what I have now:
And an example of what I'd like to accomplish:
Any and all help is appreciated, and please let me know if there is any more info that I can give that'd help out.Hi Mike,
Your screenshots show that you have merged some cells in Column A of both tables. That may be the reason why the LOOKUP function is having trouble working out which range of cells to examine.
Hope this helps.
Regards,
Ian. -
Count and limit the accesses to a browser based swf
I have a swf file imbedded in a HTML. Acceess to the file are controlled by passwords, stored in a XML-file
I want to limit the number of accesses for each visitor to let us say 10 visits. How do I count (and store) the number of logons for each visitor?
SharedObject works only at clienside, but iI want i serverside. The "easy" way would be to save the number of accesses for each visitor in a text-file but Flash and save... I hvave tried ExternalInterface calls, PHP etc and etc, but cant find a way that works. This is the last obstacle in a huge project. Please help.If using a MySQL database is an option, here's a link to a tutorial that deals with all the various aspects of that.
http://www.gotoandlearn.com/play?id=20 -
API to Update the DISCOUNT_DATE and DISCOUNT_AMOUNT_AVAILABLE column
Hi,
I am doing one inbound interface where I needs to Update the DISCOUNT_DATE and DISCOUNT_AMOUNT_AVAILABLE column in AP_PAYMENT_SCHEDULES_ALL table for each invoice. So that the value will display in Schedule Payments tab of the invoice workbench screen.
Requesting to suggest any public/private API for this process.
Any help will be needful for me
Thanks and RegardsHi,
I have a requirement where in I have to develop a report to display bank balance chart with the following details in the output.They are :
1. Posting Date
2. Bill Discount (BD)
3. Letter of Credit(LC)
4. Cheque Amount may be cheque issued.
5. Deposits.
Above are the information which i have to display based on Posting Date range , Company Code and Bank Key present in the selection-screen.
Below are my few observations:
1. To retrieve the Bill Discount, I am first fetching the data from BKPF table by checking the document types 'DZ' ,'KZ', Company code and Posting Date Range. Then using document number,company code present in these entries along with Posting key = 39 and special GL indicator = 'W' retrieving the data like DMBTR,WRBTR from BSEG.
2. Similarly for Letter of Credit amount retrieving the data in the same way as mentioned above except special GL indicator will be 'Y'.
Now please correct me if my approach is wrong. Request you all to throw some light as I am Technical Consultant and humbly looking forward to all your help.
Also, request to let me know the logic or process how one can calculate fourth point as well as Fifth point as mentioned above.
Edited by Raghavendra Kulkarni.
I am just looking for flow of data/process flow/standard transactions through which I can see these above mentioned things which can help me in building the logic. At least a general approach to this will be appreciated highly.
Regards,
Raghavendra Kulkarni. -
How to count number of columns in cross-tab report
I have created a cross-tab report and have managed to get the data out as below:
Jan Feb Mar....(display of months will auto expand) Avg/Mo Total
UserA 4 3 4 11
UserB 6 1 1 8
UserC 5 5 5 15
Total 15 9 10 33
I want to insert a calculated column (Avg/Mo) into the cross-tab report based on the formula: Total/Number of Months. I used this calculation formula for Avg.Mo column:
(GridValueAt(CurrentRowIndex, CurrentColumnIndex+1, CurrentSummaryIndex)/GetNumColumns)
However, I get the wrong average since GetNumColumns count the total number of columns including the column of Avg/Mo and Total.
How do i get the number of columns, excluding the Avg/Mo calculated column and Total column?
PS: I can't use hardcode since the number of months/columns will auto expand the months progress...
Edited by: jutamind on May 26, 2010 9:27 AMok managed to solve this by slightly changing the formula:
GridValueAt(CurrentRowIndex, CurrentColumnIndex+1, CurrentSummaryIndex)/(GetNumColumns-2) -
View with columns based on function - problem with query
Hi,
I'm using Oracle 9i;
I've created a view which has columns based on a table columns (multiple columns from 1 table) and funtion (multiple columns based on 1 function).
The function takes ID as the first argument and name of the column to determine which value to return as the second one.
Here is a sample of such function (simplified):
FUNCTION my_function
(in_id IN NUMBER, in_col_name IN VARCHAR2)
RETURN VARCHAR2
IS
c_name VARCHAR2(100);
c_last_name VARCHAR2(100);
BEGIN
SELECT T.NAME, T.LAST_NAME
INTO c_name, c_last_name
FROM TABLE_1 T, TABLE_2 Z
WHERE T.PK = Z.FK
AND Z.ID = in_id;
IF in_col_name = 'NAME' THEN
RETURN c_name;
ELSIF in_col_name = 'LAST_NAME' THEN
RETURN c_last_name;
END IF;
END;
For simplicty I've restricted the number of columns.
CREATE OR REPLACE VIEW my_view
(ID, NAME, LAST_NAME)
AS
SELECT
T.ID ID
,CAST(my_function(T.ID,'NAME') AS VARCHAR2(100)) NAME
,CAST(my_function(T.ID,'LAST_NAME') AS VARCHAR2(100)) LAST_NAME
FROM TABLE T;
There is no problem with query:
SELECT * FROM my_view;
The problem arises when I query the view (regardles of '=' or 'LIKE'):
SELECT * FROM my_view
WHERE name LIKE '%some_part_of_name%'
The query returns rows for same names, for same it doesn't. If I put '=' and the whole name the query returns nothing, but when I put 'LIKE' and the first letter it returns rows in some cases.
I've tried to debug this situation and I've discovered that the function recives ID not in the proper order and not the same amount of times - in explicit:
for each ID in (1, 2, 3, 4, 5, 6, ... , 100) the function should be called twice for each ID and in the same order, but it does not.
I get 1, 1, 2, 3, 3, 6, 20, 20 and so on.
Help needed.
Greetings.The problem is more complicated than the solutions provided here.
The reason why I'm using the function is this:
the original view was constructed using multiple union all selects and the speed was terrible. I've created the index on the base table to obtain a proper sort. For retriving all records at once the view works perfectly, but if one wants to query by columns based on function the results are suprisng - sometimes there are, some times there are none, or if you serch with "like" and only a part of string there are results, but with "=" there are no results.
Here are real DDLs:
View:
CREATE OR REPLACE VIEW V_DOK_ARCH
(ID_ZDAR, TYP, STAN, DATE_CREATED, CREATED_BY,
DATE_MODIFIED, MODIFIED_BY, SPRA_ID_SPRA, PODM_ID_PODM, PODM_UMOW_ID_UMOW,
NR_WFS, WFS_NR_INTER, UWAGI_OPER, FUNDUSZ, NUMER,
DATA_PODPISANIA, RODZAJ, TYP_PRZY, TYP_UBEZ, NAZWISKO,
IMIE, IMIE_OJCA, NAZWA_FIRMY, NAZWA_FIRMY_SKR, DANE_KLIE)
AS
SELECT /*+ INDEX(Z ZDAR_DATE_CREATED_DESC_I) */
Z.ID_ZDAR ID_ZDAR
, Z.TYP TYP
, Z.STAN STAN
, Z.DATE_CREATED DATE_CREATED
, Z.CREATED_BY CREATED_BY
, Z.DATE_MODIFIED DATE_MODIFIED
, Z.MODIFIED_BY MODIFIED_BY
, Z.SPRA_ID_SPRA SPRA_ID_SPRA
, Z.PODM_ID_PODM PODM_ID_PODM
, Z.PODM_UMOW_ID_UMOW PODM_UMOW_ID_UMOW
, Z.NR_WFS NR_WFS
, Z.WFS_NR_INTER WFS_NR_INTER
, Z.UWAGI_OPER UWAGI_OPER
, Z.FUNDUSZ FUNDUSZ
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NUMER') AS VARCHAR2(30)) NUMER
, F_Rej_Zdar_Date(Z.ID_ZDAR, 'DATA_PODPISANIA') DATA_PODPISANIA
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'RODZAJ') AS VARCHAR2(4)) RODZAJ
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_PRZY') AS VARCHAR2(4)) TYP_PRZY
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_UBEZ') AS VARCHAR2(3)) TYP_UBEZ
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO') AS VARCHAR2(30)) NAZWISKO
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE') AS VARCHAR2(30)) IMIE
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA') AS VARCHAR2(30)) IMIE_OJCA
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY') AS VARCHAR2(300)) NAZWA_FIRMY
, CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR') AS VARCHAR2(100)) NAZWA_FIRMY_SKR
, CAST(LTRIM(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA')||F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY')||DECODE(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY'),NULL,F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR'),NULL)) AS VARCHAR2(492)) DANE_KLIE
FROM T_ZDARZENIA Z
WHERE F_Rej_Zdar_Char(Z.ID_ZDAR, 'JEST') = 'T';
and functions:
CREATE OR REPLACE FUNCTION F_Rej_Zdar_Char
(WE_ID_ZDAR IN NUMBER
,WE_KOLUMNA IN VARCHAR2
RETURN VARCHAR2
IS
c_numer T_PRZYSTAPIENIA.NUMER%TYPE;--VARCHAR2(30);
c_rodzaj T_KLIENCI.RODZAJ%TYPE;--VARCHAR2(1);
c_typ_przy T_PRZYSTAPIENIA.TYP_PRZY%TYPE;--VARCHAR2(1);
c_typ_ubez T_PRZYSTAPIENIA.TYP_UBEZ%TYPE;--VARCHAR2(3);
c_nazwisko T_KLIENCI.NAZWISKO%TYPE;--VARCHAR2(30);
c_imie T_KLIENCI.IMIE%TYPE;--VARCHAR2(30);
c_imie_ojca T_KLIENCI.IMIE_OJCA%TYPE;--VARCHAR2(30);
c_nazwa_firmy T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(300);
c_nazwa_firmy_skr T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(100);
c_jest VARCHAR2(1) := 'T';
c EXCEPTION;
BEGIN
--dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR);
BEGIN
SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
WHERE p.KLIE_ID_KLIE = k.ID_KLIE
AND z.PODM_ID_PODM = D1.ID_PODM
AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
AND D2.PRZY_ID_PRZY = P.ID_PRZY
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
WHERE z.PODM_UMOW_ID_UMOW IS NULL
AND z.PODM_ID_PODM = D.ID_PODM
AND D.KLIE_ID_KLIE = k.ID_KLIE
AND p.KLIE_ID_KLIE = k.ID_KLIE
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, I.nazwisko, I.imie, I.imie_ojca, I.NAZWA NAZWA_FIRMY, I.NAZWA_SKR nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_ZDARZENIA z, T_INSTYTUCJE I
WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
AND z.PODM_UMOW_ID_UMOW IS NULL
AND Z.PODM_ID_PODM = I.ID_INST
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_ID_PODM = a.ID_AGAG
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_ID_PODM = a.ID_AGKAN
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.NUMER_UMOWY NUMER, DECODE(k.TYP_PRZYSTAPIENIA,'P','F','P') RODZAJ,k.TYP_PRZYSTAPIENIA TYP_PRZY,'NPO' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, k.nazwa_firmy nazwa_firmy, k.nazwa_firmy_skr nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND k.TYP_PRZYSTAPIENIA IN ('P','W')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.NUMER_UMOWY NUMER, 'F' RODZAJ,'-' TYP_PRZY,'OPS' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, NULL nazwisko, NULL imie_pierwsze, NULL imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
FROM T_ZDARZENIA z
WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
--dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR||' ostatni wyjatek');
NULL;
END;
END;
END;
END;
END;
END;
END;
END;
END;
END;
--raise c;
IF WE_KOLUMNA = 'NUMER' THEN
RETURN c_numer;
ELSIF WE_KOLUMNA = 'RODZAJ' THEN
RETURN c_rodzaj;
ELSIF WE_KOLUMNA = 'TYP_PRZY' THEN
RETURN c_typ_przy;
ELSIF WE_KOLUMNA = 'TYP_UBEZ' THEN
RETURN c_typ_ubez;
ELSIF WE_KOLUMNA = 'NAZWISKO' THEN
RETURN c_nazwisko;
ELSIF WE_KOLUMNA = 'IMIE' THEN
RETURN c_imie;
ELSIF WE_KOLUMNA = 'IMIE_OJCA' THEN
RETURN c_imie_ojca;
ELSIF WE_KOLUMNA = 'NAZWA_FIRMY' THEN
RETURN c_nazwa_firmy;
ELSIF WE_KOLUMNA = 'NAZWA_FIRMY_SKR' THEN
RETURN c_nazwa_firmy_skr;
ELSIF WE_KOLUMNA = 'JEST' THEN
RETURN c_jest;
END IF;
END;
CREATE OR REPLACE FUNCTION F_Rej_Zdar_Date
(WE_ID_ZDAR IN NUMBER
,WE_KOLUMNA IN VARCHAR2
RETURN DATE
IS
d_data DATE;
BEGIN
BEGIN
SELECT p.DATA_PODPISANIA
INTO d_data
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
WHERE p.KLIE_ID_KLIE = k.ID_KLIE
AND z.PODM_ID_PODM = D1.ID_PODM
AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
AND D2.PRZY_ID_PRZY = P.ID_PRZY
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISANIA
INTO d_data
FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
WHERE z.PODM_UMOW_ID_UMOW IS NULL
AND z.PODM_ID_PODM = D.ID_PODM
AND D.KLIE_ID_KLIE = k.ID_KLIE
AND p.KLIE_ID_KLIE = k.ID_KLIE
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL DATA_PODPISANIA
INTO d_data
FROM T_ZDARZENIA z, T_INSTYTUCJE I
WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
AND z.PODM_UMOW_ID_UMOW IS NULL
AND Z.PODM_ID_PODM = I.ID_INST
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISANIA DATA_PODPISANIA
INTO d_data
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISANIA DATA_PODPISANIA
INTO d_data
FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
WHERE a.ID_AGAG = p.AGAG_ID_AGAG
AND z.PODM_ID_PODM = a.ID_AGAG
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
INTO d_data
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
INTO d_data
FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
AND z.PODM_ID_PODM = a.ID_AGKAN
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
INTO d_data
FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND k.TYP_PRZYSTAPIENIA IN ('P','W')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
INTO d_data
FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
BEGIN
SELECT NULL DATA_PODPISANIA
INTO d_data
FROM T_ZDARZENIA z
WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
AND z.PODM_ID_PODM IS NULL
AND z.PODM_UMOW_ID_UMOW IS NULL
AND z.ID_ZDAR = WE_ID_ZDAR;
EXCEPTION
WHEN NO_DATA_FOUND THEN
d_data := NULL;
END;
END;
END;
END;
END;
END;
END;
END;
END;
END;
IF WE_KOLUMNA = 'DATA_PODPISANIA' THEN
RETURN d_data;
END IF;
END; -
Disclaimer: I'm not a computer guy but I can be taught!
I am tracking a checking account for a church ministry. I have one table that holds the line items and the amounts budgeted for each item. I want to add a column to that table that shows the actual amount spent for that line item. The reference will come from the second table that contains that actual data. I have a column that has a dropdown list to select the budget line item and a column that holds the actual amount spent for that transaction. I want to auto sum the selected currency values based on the selection criteria of the certain budget line item and display it in the first table.
Any help would be appreciated.Hi wcanerday,
Thanks for the green tick and your feedback. Yes, the SUMIF function is powerful!
When you adapt the Personal Budget template, make sure that the items in the Category Column (A) on the Budget sheet exactly match the items in the Pop-Up Menus in Column C of the Transactions sheet.
Editing a Pop-Up Menu in Numbers 3 is easy. Please call back if you need more help.
Regards,
Ian. -
Provide a count of different columns
I have the need to count two columns using two tables. table1 looks like:
id itemid itemid2 count_item count_item2
1 123 45 3 null
2 425 46 3 null
table2 looks like:
kID itemid history
1 123 week1
2 123 week2
3 123 week3
4 425 week1
5 425 week2
6 425 week3
7 235 week1
8 235 week2
9 235 week3
So during an insert(or update), such as 'INSERT INTO table1(itemid,itemid2)VALUES(235, 123), table 1 becomes...
id itemid itemid2 count_item count_item2
1 123 45 3 null
2 425 46 3 null
3 235 123 3 null
because the following Trigger below takes effect:
CREATE TRIGGER UpdateHistoryON table1FOR INSERT, UPDATEASIF @@ROWCOUNT = 0RETURNSET NOCOUNT ONIF EXISTS (SELECT * FROM inserted)with count_table AS
SELECT Itemid, count(*) AS count_item FROM table2
GROUP BY ItemId
UPDATE table1
SET table1.count_item = CT.count_item
FROM count_table CT
INNER JOIN table1
ON (CT.ItemId = table1.ItemId)
INNER JOIN inserted I
ON I.ItemId = table1.ItemId
And this is where I need you expertise: I want the count of 'itemid2' also(in the same trigger) so that after the insert above, table1 should become:
id itemid itemid2 count_item count_item2
1 123 45 3 null
2 425 46 3 null
3 235 123 3 3Hi,
It is looking like a lot of duplicate data, but if this is what you want, and this trigger work for you in the way that you want for column count_item ,then you can just use the same and SET (updates) two column. instead of using
SET T1.count_item = CT.count_item
You can use
SET T1.count_item = CT.count_item, T1.count_item2 = CT.count_item2
and in the CTE add the column count_item2 which will do the count on the item2.
assuming that I understand your request correctly :-)
If this is the case then this is not a trigger question but an update issue, buy the way (how to update two column based on select query result).
http://www.w3schools.com/sql/sql_update.asp
[Personal Site] [Blog] [Facebook] -
Hide column based on parameter value
Hi All,
I have requirement where i need to hide one column based on my input parameter value.per example
if my parameter say DISPLAY is Yes then i need to hide the column AMOUNT..
how to achieve this... Please help.
Thanks
BharatHi Bharat,
You can do it following the steps explained in the documentation :
http://docs.oracle.com/cd/E12844_01/doc/bip.1013/e12187/T421739T481157.htm#4535373
regards
Jorge
p.s. If this answers your question then please grant the points and close the thread -
Calculating distinct counts of dimension columns
Hi, OBIEE Gurus. Here's today's question on the quiz show "Can this be done?".
Month
Region
Sales
# Months
# Regions
Jan-2013
East
1000
2
3
Jan-2013
Central
2000
2
3
Jan-2013
West
3500
2
3
Feb-2013
East
1250
2
3
Feb-2013
Central
1925
2
3
Feb-2013
West
3450
2
3
The # Months and # Regions columns are the goal today. There are two months in this analysis (Jan-2013, Feb-2013), out of a total population of 96 months. There are three regions in this analysis (East, Central, West) out of a total population of 7 regions. I want those values (2 and 3, respectively) reflected in the # Months and # Regions columns.
I've tried various combinations of the usual suspects (count, count distinct, sum(count..., sum(count distinct... and so forth) but I haven't found the correct magic spell yet. Any ideas?I found one potential (but somewhat flawed) solution for # Months:
count(distinct aggregate("Facts"."Sales" at "Geographies"."Geography"."Total Locales"))
Region is part of my Geography hierarchy, whose highest level is Total Locales. This says to calculate sales for each row for the Total Locales level, so essentially ignore the Region column. The flaw here is that two different months that just happen to have exactly the same sales will only generate one distinct value of sales, so there is the potential to undercount. (I can get around it with a minor calculation, but that's just another complication.)
It also seems rather clunky, because it has to be modified to accommodate any newly added columns and (basically) create a level-based fact for the highest level of every hierarchy represented except for the column of interest. So it's not very pretty solution.
If you have anything more elegant, bring it on.
Maybe you are looking for
-
I keep get an internal ichat error has accord each time I try and open it. It was working fine earlier today so I don't know what is causing the problem. I'm attaching the info that it sends to apple. Process: iChatAgent [367] Path: /System/Library/F
-
Blank message when I send a video via a text message
I got a replacement iPhone 4s last week. Whenever I try and send a video (shot using the phone) via text message, the recipient (who uses an iPhone) gets a blank message, but are able to get pictures? Do I need to check certain settings?
-
Can I link two ipads to one macbook pro?
Can I link two ipads to one macbook pro?
-
How to get the value of the global variable of test stand in labview User interface?
Hi. Can anyone Please share examples and tell me to how access the test stand global variable using labview user interface. Solved! Go to Solution.
-
What is best techniques for Replication
Hi. I want to implement Replication for the database. So i want to know what is the best way to do this? Is snapshot is useful for this? What is the best, efficient and CHEAPER method to implement replication? cheaper means, I do not want to use Data