Counting records in a query
Hello all,
I have a question about the counting of records in a query.
Below, there is the source data.
material plant date stock quantity
X 1 05.2006 10
X 1 06.2006 0
X 2 05.2006 15
X 2 04.2006 20
Y 1 05.2006 5
And with "How to Count the occurrences ..." guide , i created the following query.
material quantity number of plants with stock
X 45 2
Y 5 1
My question is in the second step , is it possible in the same query to get the following result for a given date ?
If this is not the case, how can I resolve this ?
material quantity nb of plants with stck nb of plants with stck >= 15
X 45 2 1 (10 for 1 and 35 for 2)
Y 5 1 0
Thanks&Regards
Burak
Create a display item to hold the count value. Then open the data block properties and under advanced database set precompute summaries to "yes". Then in your display item properties set the summary function to count; the summarized block to the block_name; and summarized item to any block item you would like to count.
Hope this is clear and what you are looking for.
Cheers.
Similar Messages
-
Counting records after a query
I am running a query and I want to display the number of records retrieved during the query. I have researched the COUNT_QUERY built-in and tried to assign the value returned by this built-in to a variable. (It doesn't work.) I have used the the following statement within the WHEN-BUTTON-PRESSED trigger for a Push Button on my form:
SELECT COUNT(:BLOCK.ITEM)
INTO :BLOCK.ITEM2
FROM DUAL;
This statement is not providing a valid number for the number of records returned.
Is there a function that I can use to count the number of records returned from a query?Create a display item to hold the count value. Then open the data block properties and under advanced database set precompute summaries to "yes". Then in your display item properties set the summary function to count; the summarized block to the block_name; and summarized item to any block item you would like to count.
Hope this is clear and what you are looking for.
Cheers. -
Counting Record Totals Within Query: Totals Output to New Table
Hi All,
I'm failry new to PL/SQL... my apologies if this is obvious... I'm trying to count the total number of BI_WRKFLW.BI_LMN_SRV_AREA occurences by each BI_WRKFLW.BI_LMN_SRV_AREA (The Code correspondes to a city name like Sundance, Sheridan, Etc.)
So, I have a Query that executes fine:
Query
/* Begin Querey */
SELECT DISTINCT
"BI_SO_DET_VIEW_1"."BI_SO_STAT_CD",
"BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED",
"BI_TYPE_SERVICE"."BI_ACCT",
"BI_SO_DET_VIEW_1"."BI_SO_NBR",
"BI_LMN_SRV_REF"."BI_LMN_SRV_DESC",
"BI_SO_TYPE_REF"."BI_SO_TYPE_DESC",
"BI_SRV_STAT_REF"."BI_SRV_STAT_DESC",
"BI_DIST_OFC_REF"."BI_DIST_NAME",
"BI_CNTY_REF"."BI_COUNTY_DESC",
"BI_SO_DET_VIEW_1"."BI_CLOSE_DT",
"BI_WRKFLW_TASKS"."BI_EVENT_DT_TM",
"BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD",
"BI_LMN_SRV_REF"."BI_LMN_SRV_AREA",
"BI_SO_MASTER"."BI_WO_WORKORD"
FROM
((((((((("XXXXXX"."BI_SO_MASTER" "BI_SO_MASTER"
LEFT OUTER JOIN
"XXXXXX"."BI_SO_DET_VIEW_1" "BI_SO_DET_VIEW_1"
ON
"BI_SO_MASTER"."BI_SO_NBR"="BI_SO_DET_VIEW_1"."BI_SO_NBR")
LEFT OUTER JOIN
"XXXXXX"."BI_TYPE_SERVICE" "BI_TYPE_SERVICE"
ON
"BI_SO_DET_VIEW_1"."ACCT_NBR"="BI_TYPE_SERVICE"."BI_ACCT")
LEFT OUTER JOIN
"XXXXXX"."BI_WRKFLW" "BI_WRKFLW"
ON
"BI_SO_DET_VIEW_1"."BI_WRKFLW_KEY"="BI_WRKFLW"."BI_WRKFLW_KEY")
LEFT OUTER JOIN
"XXXXXX"."BI_SO_TYPE_REF" "BI_SO_TYPE_REF"
ON
"BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"="BI_SO_TYPE_REF"."BI_SO_TYPE_CD")
LEFT OUTER JOIN
"XXXXXX"."BI_WRKFLW_TASKS" "BI_WRKFLW_TASKS"
ON
"BI_WRKFLW"."BI_WRKFLW_KEY"="BI_WRKFLW_TASKS"."BI_WRKFLW_KEY")
AND (
"BI_WRKFLW"."BI_WORK_EVENT_CD"="BI_WRKFLW_TASKS"."BI_WORK_EVENT_CD"))
LEFT OUTER JOIN
"XXXXXX"."BI_DIST_OFC_REF" "BI_DIST_OFC_REF"
ON
"BI_WRKFLW"."BI_DIST_OFC_CD"="BI_DIST_OFC_REF"."BI_DIST_OFC_CD")
LEFT OUTER JOIN
"XXXXXX"."BI_LMN_SRV_REF" "BI_LMN_SRV_REF"
ON
"BI_WRKFLW"."BI_LMN_SRV_AREA"="BI_LMN_SRV_REF"."BI_LMN_SRV_AREA")
LEFT OUTER JOIN
"XXXXXX"."BI_SRV_LOC" "BI_SRV_LOC"
ON
"BI_TYPE_SERVICE"."BI_SRV_LOC_NBR"="BI_SRV_LOC"."BI_SRV_LOC_NBR")
LEFT OUTER JOIN
"XXXXXX"."BI_SRV_STAT_REF" "BI_SRV_STAT_REF"
ON
"BI_TYPE_SERVICE"."BI_SRV_STAT_CD"="BI_SRV_STAT_REF"."BI_SRV_STAT_CD")
LEFT OUTER JOIN
"XXXXXX"."BI_CNTY_REF" "BI_CNTY_REF"
ON
"BI_SRV_LOC"."BI_CNTY_CD"="BI_CNTY_REF"."BI_CNTY_CD"
WHERE
"BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='011'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='011NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='020'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='020NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='030'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='040'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='041'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='050'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='050A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='051'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='051A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='080'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='085'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='085NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='108'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='140'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='141'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='400'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='401'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='450'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='450A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='451'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='451A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='452'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='452A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='453'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='453A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='460'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHR'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHRNS')
AND "BI_SO_DET_VIEW_1"."BI_SO_STAT_CD"='O'
AND (
"BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='ANNEXATION'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='AVIAN'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CAPVERIF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CBMRETIRE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CBMSERVCHG'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CONTSERVD'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CUSTBLD'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CUTOFF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='DVCM'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='ENERGIZE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='EQUIPCHANG'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='EQUIPVALID'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='HIGHLOAD'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='LOCATE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='MAINT-EQ'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='MSYSTEMMGT'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NCBM'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NEWRES-WF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NEW-WF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='POWER QUAL'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RECONIDLE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RECVERIF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RETIRE1'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RETIRE2'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SERVCHANGE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SPECIALPRJ'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SUBD'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SYSTEMMGT'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='TREE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='TRFX')
ORDER BY
"BI_LMN_SRV_REF"."BI_LMN_SRV_DESC" DESC,
"BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"
/* End Querey */That is wrapped within a counting Block that is giving me trouble:
SELECT
WOCOUNT.Office,
WOCOUNT.WOCOUNT
FROM
SELECT
CASE
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '1'
THEN '1-SUNDANCE'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '2'
THEN '2-GILLETTE'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '3'
THEN '3-SHERIDAN'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '4'
THEN '4-West/Central'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '5'
THEN '5-East/Central'
ELSE '0-OTHER'
END AS Office,
COUNT (T1.BI_LMN_SRV_AREA ) AS WOCOUNT
FROM
/* Begin Querey */
/* End Querey */
) T2
JOIN
BI_SO_DET_VIEW_1
ON
T2.BI_WRKFLW_KEY = BI_SO_DET_VIEW_1.BI_WRKFLW_KEY
GROUP BY
BI_WRKFLW.BI_LMN_SRV_AREA
)WOCOUNTThis is the 2 blocks together:
SELECT
WOCOUNT.Office,
WOCOUNT.WOCOUNT
FROM
SELECT
CASE
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '1'
THEN '1-SUNDANCE'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '2'
THEN '2-GILLETTE'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '3'
THEN '3-SHERIDAN'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '4'
THEN '4-West/Central'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '5'
THEN '5-East/Central'
ELSE '0-OTHER'
END AS Office,
COUNT (T1.BI_LMN_SRV_AREA ) AS WOCOUNT
FROM
/* Begin Querey */
SELECT DISTINCT
"BI_SO_DET_VIEW_1"."BI_SO_STAT_CD",
"BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED",
"BI_TYPE_SERVICE"."BI_ACCT",
"BI_SO_DET_VIEW_1"."BI_SO_NBR",
"BI_LMN_SRV_REF"."BI_LMN_SRV_DESC",
"BI_SO_TYPE_REF"."BI_SO_TYPE_DESC",
"BI_SRV_STAT_REF"."BI_SRV_STAT_DESC",
"BI_DIST_OFC_REF"."BI_DIST_NAME",
"BI_CNTY_REF"."BI_COUNTY_DESC",
"BI_SO_DET_VIEW_1"."BI_CLOSE_DT",
"BI_WRKFLW_TASKS"."BI_EVENT_DT_TM",
"BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD",
"BI_LMN_SRV_REF"."BI_LMN_SRV_AREA",
"BI_SO_MASTER"."BI_WO_WORKORD"
FROM
((((((((("XXXXXX"."BI_SO_MASTER" "BI_SO_MASTER"
LEFT OUTER JOIN
"XXXXXX"."BI_SO_DET_VIEW_1" "BI_SO_DET_VIEW_1"
ON
"BI_SO_MASTER"."BI_SO_NBR"="BI_SO_DET_VIEW_1"."BI_SO_NBR")
LEFT OUTER JOIN
"XXXXXX"."BI_TYPE_SERVICE" "BI_TYPE_SERVICE"
ON
"BI_SO_DET_VIEW_1"."ACCT_NBR"="BI_TYPE_SERVICE"."BI_ACCT")
LEFT OUTER JOIN
"XXXXXX"."BI_WRKFLW" "BI_WRKFLW"
ON
"BI_SO_DET_VIEW_1"."BI_WRKFLW_KEY"="BI_WRKFLW"."BI_WRKFLW_KEY")
LEFT OUTER JOIN
"XXXXXX"."BI_SO_TYPE_REF" "BI_SO_TYPE_REF"
ON
"BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"="BI_SO_TYPE_REF"."BI_SO_TYPE_CD")
LEFT OUTER JOIN
"XXXXXX"."BI_WRKFLW_TASKS" "BI_WRKFLW_TASKS"
ON
"BI_WRKFLW"."BI_WRKFLW_KEY"="BI_WRKFLW_TASKS"."BI_WRKFLW_KEY")
AND (
"BI_WRKFLW"."BI_WORK_EVENT_CD"="BI_WRKFLW_TASKS"."BI_WORK_EVENT_CD"))
LEFT OUTER JOIN
"XXXXXX"."BI_DIST_OFC_REF" "BI_DIST_OFC_REF"
ON
"BI_WRKFLW"."BI_DIST_OFC_CD"="BI_DIST_OFC_REF"."BI_DIST_OFC_CD")
LEFT OUTER JOIN
"XXXXXX"."BI_LMN_SRV_REF" "BI_LMN_SRV_REF"
ON
"BI_WRKFLW"."BI_LMN_SRV_AREA"="BI_LMN_SRV_REF"."BI_LMN_SRV_AREA")
LEFT OUTER JOIN
"XXXXXX"."BI_SRV_LOC" "BI_SRV_LOC"
ON
"BI_TYPE_SERVICE"."BI_SRV_LOC_NBR"="BI_SRV_LOC"."BI_SRV_LOC_NBR")
LEFT OUTER JOIN
"XXXXXX"."BI_SRV_STAT_REF" "BI_SRV_STAT_REF"
ON
"BI_TYPE_SERVICE"."BI_SRV_STAT_CD"="BI_SRV_STAT_REF"."BI_SRV_STAT_CD")
LEFT OUTER JOIN
"XXXXXX"."BI_CNTY_REF" "BI_CNTY_REF"
ON
"BI_SRV_LOC"."BI_CNTY_CD"="BI_CNTY_REF"."BI_CNTY_CD"
WHERE
"BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='011'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='011NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='020'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='020NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='030'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='040'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='041'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='050'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='050A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='051'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='051A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='080'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='085'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='085NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='108'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='140'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='141'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='400'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='401'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='450'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='450A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='451'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='451A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='452'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='452A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='453'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='453A'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='460'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHR'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHRNS')
AND "BI_SO_DET_VIEW_1"."BI_SO_STAT_CD"='O'
AND (
"BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='ANNEXATION'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='AVIAN'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CAPVERIF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CBMRETIRE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CBMSERVCHG'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CONTSERVD'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CUSTBLD'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='CUTOFF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='DVCM'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='ENERGIZE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='EQUIPCHANG'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='EQUIPVALID'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='HIGHLOAD'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='LOCATE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='MAINT-EQ'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='MSYSTEMMGT'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NCBM'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NEWRES-WF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='NEW-WF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='POWER QUAL'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RECONIDLE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RECVERIF'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RETIRE1'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='RETIRE2'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SERVCHANGE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SPECIALPRJ'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SUBD'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='SYSTEMMGT'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='TREE'
OR "BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"='TRFX')
ORDER BY
"BI_LMN_SRV_REF"."BI_LMN_SRV_DESC" DESC,
"BI_SO_DET_VIEW_1"."BI_SO_TYPE_CD"
/* End Querey */
) T2
JOIN
BI_SO_DET_VIEW_1
ON
T2.BI_WRKFLW_KEY = BI_SO_DET_VIEW_1.BI_WRKFLW_KEY
GROUP BY
BI_WRKFLW.BI_LMN_SRV_AREA
)WOCOUNTThe last error I received is: [Error Code: 904, SQL State: S0022] [Oracle][ODBC][Ora]ORA-00904: "T2"."BI_WRKFLW_KEY": invalid identifier
I want the final Output to be something similar to:
OFFICE WOCOUNT
0-OTHER 44.0
1-SUNDANCE 14.0
2-GILLETTE 29.0
3-SHERIDAN 11.0
4-West/Central 37.0
5-East/Central 58.0 Thanks for your help,
:) JohnHi, John,
Johnbr (Oracle11G) wrote:
Hi All,
I'm failry new to PL/SQL... That's okay; there's no PL/SQL involved in this problem, and there's no PL/SQL needed, only SQL.
That is wrapped within a counting Block that is giving me trouble:
SELECT
WOCOUNT.Office,
WOCOUNT.WOCOUNT
FROM
SELECT
CASE
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '1'
THEN '1-SUNDANCE'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '2'
THEN '2-GILLETTE'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '3'
THEN '3-SHERIDAN'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '4'
THEN '4-West/Central'
WHEN "BI_WRKFLW"."BI_LMN_SRV_AREA" = '5'
THEN '5-East/Central'
ELSE '0-OTHER'
END AS Office,
COUNT (T1.BI_LMN_SRV_AREA ) AS WOCOUNT
FROM
/* Begin Querey */
/* End Querey */
) T2
JOIN
BI_SO_DET_VIEW_1
ON
T2.BI_WRKFLW_KEY = BI_SO_DET_VIEW_1.BI_WRKFLW_KEY
GROUP BY
BI_WRKFLW.BI_LMN_SRV_AREA
)WOCOUNT
The sub-query called wocount only involves 2 "tables", namely
(1) T2
(2) BI_SO_DET_VIEW_1
(I put "tables" in quotes because T2 isn't really a table; it's an in-line view. Judging by the name, I'm guessing BI_SO_DET_VIEW_1 isn't really a table, either, but it doesn't matter. You have 2 things that serve as tables, so I'll just call them tables.)
Since those are the only 2 tables, you can't reference BI_WRKFLW in WOCOUNT. That table is known inside T2, but not outside of T2.
You can include "BI_WRKFLW"."BI_LMN_SRV_AREA" in the SELECT clause of T2, assuming that doesn't make more rows distinct. T2 will then look like this:
... SELECT DISTINCT
BI_SO_DET_VIEW_1.BI_SO_STAT_CD
BI_SO_MASTER.BI_WO_WORKORD,
BI_WRKFLW.BI_LMN_SRV_AREA -- New column added
FROM ...Then, inside WOCOUNT, you can use BI_LMN_SRV_AREA like this:
... CASE
WHEN BI_LMN_SRV_AREA = '1'
THEN '1-SUNDANCE'
WHEN BI_LMN_SRV_AREA = '2'
THEN '2-GILLETTE'
WHEN BI_LMN_SRV_AREA = '3'
THEN '3-SHERIDAN'
WHEN BI_LMN_SRV_AREA = '4'
THEN '4-West/Central'
WHEN BI_LMN_SRV_AREA = '5'
THEN '5-East/Central'
ELSE '0-OTHER'
END AS Office,or, to save a little typing:
... CASE BI_LMN_SRV_AREA
WHEN '1'
THEN '1-SUNDANCE'
WHEN '2'
THEN '2-GILLETTE'
WHEN '3'
THEN '3-SHERIDAN'
WHEN '4'
THEN '4-West/Central'
WHEN '5'
THEN '5-East/Central'
ELSE '0-OTHER'
END AS Office,
Speaking of saving on typing:
Instead of
WHERE
"BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='001NS'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='010'
OR "BI_TYPE_SERVICE"."BI_PRIM_RATE_SCHED"='RHRNS'
)you can use the IN operator, like this:
WHERE BI_TYPE_SERVICE.BI_PRIM_RATE_SCHED IN ('001', '001NS', '010', ..., 'RHRNS')
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Simplify the problem as much as possible. For example, you would probably have the same problem if there were only 2 o4 3 tables involved in your query. Try to construct a problem that only has 2 or 3 tables, and post only those tables, and the results you want from them.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using. -
How to count values in a query ?
Hi experts,
We have a query, which is having only characteristics. There are no key figures.
There is date field. In this date field the value may be or may not be there.
My requirement is if the date field has value then it should be counted record wise and the total count
should be displayed in the bottom of the query output. If value is not there then that record should not be
counted.
How can we do this ?
Regards,
Nishuv.Dear Nishuv,
You can create a calculated keyfigure for getting count, in that create a formula variable on characterstic with replacement as processing type.
and please clarify on what level you wanted to count, like Sales Docuement level or Item level.
For Example :
If you wanted to find no.of sales orders which are returned so you have to count on document level. this would be the replacement characterstic.
Please find the below PDf you will understand better
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/009819ab-c96e-2910-bbb2-c85f7bdec04a
Thanks
Sreekanth -
Counting records in Visual Composer
Hi folks,
I do have question I cannot find a solution ( maybe due to christmas turkey paralysis )
I am using VC to call a RFC function in ERP system 'RFC_READ_TABLE' to access data from table.
The table I access is a customer table containing Delta- Data
Actually the system RFC function returns all records ( normally between 1 and 10 records).
On VC side I'd like to display only the number of records to inform if new data is available.
How can I count records internally in VC?
( I do not like to bring in data directly into BI because the application I write will merge BI Query data with non BI data)
I'D like to use standard RFC function to receive data, but first hand I'd like to decide by number of entries whether to use data or not.
Any help is appreciated
TIAHi Prachi,
that's it.
I never used that functionality for plain counting records being returned by tables
It woks perfect.
The glory shiny points are yours.
Joerg -
How to count records from 2 tables and show in RDLC Report
hi all,
its being a one day searching for the solution but No Luck.
I have two SQL tables tblstudetail and tblfeereceiptdetail.
i just want to count records from both tables and show in RDLC report.
I tried SQl Query Like This:
select a.session, a.course,
Count(CASE a.ADstatus WHEN 'OK' THEN 1 ELSE 0 END ) AS Admission,
Count(CASE s .I_receiptstatus WHEN 'OK' THEN 1 ELSE 0 END) AS Feeprint
from
tblstudetail a
FULL join
tblfeereceiptdetail s on s.studentID = a.studentID
where a.session = '2015' AND s.Fsession = '2015' AND a.adcat = 'Regular'
GROUP BY a.session,a.course
ORDER by a.course
The result Show the Same Value in Both columns
Session Course Admission FeeDetail
2015 B.A. I 275 275
2015 B.A. II 307 307
2015 B.A. III 255 255
2015 B.Sc. I 110 110
2015 B.Sc. II 105 105
2015 B.Sc. III 64 64
Actully I want to Count How many ADMISSION have been Taken(FROM tblstudetail) and How many FEE RECEIPT have been Print (From tblfeereceiptdetail).
please guide me for this as soon as possible.
thanks in advance...I am counting 'OK' in both the table columns I.e 'ADstatus' in tblstudetail and 'feereceiptstatus' in tblfeereceiptdetail
please suggest me -
Hi All,
I'm using form builder 6i, I have a browsing Tab in my form that have one block and a lot of check boxes (5) for browse criteria that can be checked and concatenated together with || 'and' into a variable (condition) to make a (value) for the (Default_Where) property of the block.
As you know I can't issue a statement like this:
Select count(*) into count from MyTable where condition;
it causes an exception because select statement needs to state column names in where caluse, but I can just use the accumulated condition in the manner below:
set_block_property('MyBLOCK',default_where,condition);
I used it to execute the query, and it works well...but the problem is that I want to know the number of records returned from query in order to show it in a display item for the browser.
So...what I have to do ?? Any clue?
Thanks,
LoveSoulHi
u can also try...
If you want a rough hit count, you can use CTX_QUERY.COUNT_HITS in estimate mode (EXACT parameter set to FALSE).
With respect to response time, this is the fastest count you can get.
To count the number of hits returned from a query that contains a structured predicate, use the COUNT(*) function in a SELECT statement.
here is an example...
DECLARE
v_count NUMBER;
BEGIN
v_count := ctx_query.count_hits(index_name => my_index, text_query => 'oracle',
exact => TRUE);
:count =v_count; -- count display the result
END;Hope this helps...
Regards,
Abdetu... -
Conditionally disabling record updation after query
Dear members
I've a single record block and I wanna conditionaly disable records updation after query has fetched data. Problem is that if I disable the record updation in Post-Query trigger then it checks the condition for the very first fetched record and it the condition is true, then Updation is disabled for all the fetched records, even if the next records dont meet the condition. I'm using forms-10g. Can u give a better solution??? thanx.you have to use SET_ITEM_INSTANCE_PROPERTY to modify only one record:
BEGIN
IF ... <your_condition> THEN
SET_ITEM_INSTANCE_PROPERTY('YOUR_BLOCK.YOUR_ITEM1', UPDATE_ALLOWED, PROPERTY_FALSE);
ELSE
SET_ITEM_INSTANCE_PROPERTY('YOUR_BLOCK.YOUR_ITEM1', UPDATE_ALLOWED, PROPERTY_TRUE);
END IF;
END; -
How to insert the records using sql query
hi,
i insert the record uisng sql query and DOTNET programme successfully and increase the doc num .ubut when i try to add record using SAP B1 the old Doc no show.It means its not consider the docnums which are not inserted by sql query.
how can i solve this problem?
Regards,
M.Thippa ReddyYou are not support use Insert / Update / Delete on SAP Databases directly.
SAP will not support any database, which is inconsistent, due to SQL-Queries, which modify datasets or the datastructure of the SAP Business One Database. This includes any update-, delete- or drop-statements executed via SQL-Server Tools or via the the query interface of SAP Business One
Check SAP Note: 896891 Support Scope for SAP Business One - DB Integrity
[https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/smb_searchnotes/display.htm?note_langu=E¬e_numm=896891] -
How to display records from a query into non-database field
Hi
I a have a problem:
I have a query with many tables and 6 column(select a,b,c,d,e,f from x,y,z,t,s,g where conditions) and I use 3 parameters.
I create 3 parameters :datai,:dataf and :partener and a button with a trigger when button is pressed.
Then a create a manualy block with six field non-database a1,b1,c1,d1,e1,f1.
Now I want to display all the records from my query into a1,b1,c1,d1,e1,f1 where a1=a,b1=b,etc. and all the records (if I have 20 record, it will display 20 records in non-database field) when I press the button.
How I made:
I create a cursor with query then
begin open cursor
loop
fetch cursor into :a1,:b1,:c1,:d1,:e1,:f1;
end loop;
close cursor;
end;
It display one record in a1,b1,c1 only and it have to display 100 records and are date for all the fields.
Can somebody help me in this problem?
Thanks.
Edited by: 928437 on Oct 1, 2012 2:55 AMCreating a view, and querying that into a database block is an excellent solution.
To use the non-database block:
You're missing the all-important Next_Record; command.
<pre> Begin
Go_block('X'); -- block X is the non-database block
Clear_Block(No_Validate);
open cursor X1;
loop
If :System.Record_status != 'NEW' then
Next_Record;
End if;
fetch X1 into :a1,:b1,:c1,:d1,:e1,:f1;
Exit when X1%NOTFOUND;
end loop;
close X1;
end;</pre> -
Counting records in crosstab report
I am very new to the reporting world so apologies if this seems so simple.
I am trying to understand how count records that meet certain criteria and I am at a loss as to how to make it work (Crystal Reports 2008)
I am setting up a cross tab report where I am want to count records that vwSubscription.status="Active" AND vwSubscription.isDues=True
I think I should be creating a Formula Field that tests the status and dues record and when they both meet the correct criteria then have the Formula Field in the Summarized field of the Cross Tab Expert...
make sense? please helpYes. You should create a formula like this
IF vwSubscription.status="Active" AND vwSubscription.isDues=True THEN
1
And in Cross tab Create A Sum of this field under Summary fields.
If you want this value to be displayed based on some group, cross tab will be a good option, else you can create a sum of this field and place it in Report header to get the total.
HTH,
Jyothi -
How to count records in a page which are in detail section
Hi
Is there a option to count records in detail section and so that based on that can apply a formula.Hi
can i place the below two formulas in section experpt ?
my report is like
gh#1
details-----which contains transactions related to above group for a country
group footer#1contains line '--
if for india there are 3 records in the same page there can be 2 or 3 records in detail section. like that a page can contain more than one country. if number of records are more and coming in next page then the whole section should be moved to new page.
that is my req. can u suggest accordingly.....
i want to count the number of records in detais which will vary also how can i put formula when they are going to next page? -
Moving to current record after execute query
Hi all,
I have a form where i can list all db jobs which can be start or stop.
for more details, form is having columns like jobs, current db status, action(start/stop drop down)
The user will view list of jobs in the screen and he straightly goes to a record and start (submit) the job using drop down for that record.
once they start/stop the job, execute query will fire to show the current status of the job.
Now going to my requirement,after execute query, I want to go to the record (job) which user has started the job .
Currently the cursor will go to first record.
Is there any oracle 10g AS property where i can get current record , put it in parameter and go to that record after execute query?
Is there any other way?
Regards,
LeonardHello,
If you are sure the record after query will keep the same position, you can before, store the current record in a number variable with Get_Block_Property( CURRENT_RECORD) built-in, then after query use the Go_Record() with stored number variable in parameter.
If you think that after re-query the record number can change, you have to loop through your records, then stop navidation while you find the corresponding key.
Francois -
Duplicate Records in ABAP Query
I have prepared ABAP query with tables KNA1, KNB1, BSID. I have mapped only BUKRS and KUNNR from BSID . as I don't have any condition to map the fields. I want only one record for considering KUNNR and BUKRS in report . But in report It is displaying all entries from BSID considering BUKRS and KUNNR means for documents all line items.Kindly suggest as soon. How to avoid such duplicate records
Hi,
Duplicate Records in ABAP Query
Regarding on your problem,
Use these link, It will helps to your post
ABAP Querry Duplicate entries
Regards,
Sekhar -
Mysql database, counting records
Hi!
I have to store measured data to MySQL database. During this process I would like to count a number of records in a database table. It is also necessary to filter records. I'm using the SQL statement as follows:
SELECT COUNT (fieldname) AS cnt FROM table WHERE condition
Because I haven't got any result I've created a small database "mysweetdb" and table "icecream" to test my VIs (see picture bellow).
The VI is attached. The result of counting is a 2D array (DB Tools Fetch Recordset Data.VI output) with one element (one row and one column). This element contains no data.
I usually don't give up easily so I've created a similar MS ACCESS database and counted data in it. I've got a correct answer: 3. So it might be possible that there is something wrong with MySQL driver. But I've created a small Delphi project and I've counted records in MySQL database and MS ACCESS database. Both results were correct.
Can anyone explain where is the problem in communication between LabView and MySQL database?
Versions: XAMPP for Windows 1.7.3, LabView Developer Suite 2010 SP1, MySQL 5.1 ODBC driver
Thanks in advance for your suggestions.
Attachments:
Count records.vi 19 KBContDivConsult,
thank you for your answer. An updated version of my VI is attached. It uses two options: LabSQL library and DB Connectivity Toolkit. LabSQL gives correct results.
Regards,
Ljubo.
Attachments:
Count records.vi 25 KB
Maybe you are looking for
-
Hi all, What is the Premiere equivalent of the HUE/SATURATION adjustment layer found i Photoshop ? I am trying to slightly desaturate (about -53%) my movie to give it a more gritty look. I could easily get the look I wanted in Photoshpo by going to N
-
How do you make more iCloud calendars?
I notice when I go to calenders in the calenders app there's only home and work, how do I create more?
-
Good morning. Reciently I purchased some Ultra 40 M2's for our lab. Last week we had a requirement for a machine to be built with Vista and SLI so I decided to scrap RHEL and load Vista on one of the spare 40's. After installing and updating to SP1,
-
Urg: Effort Estimation of Migration Work, Any standards !
Hi, I wanted to know is there any "standard" of estimating the "work effort" (In person-months or in other terms) to establish the fact of actual work to be done. Like, is there any category of migration eg. complex, simple etc. Could you please help
-
Compter won't wake from sleep mode
My Pavilion 17 notebook computer, purchased in Oct. '13, won't wake from sleep mode; I must shut down and reboot each time. I know this is not due to Windows 8, as I have another Win 8 computer that works normally.