How to get the max(level)?
Hi,
The below query returns level and other selected columns.
I need to get the max(level) 2nd column value in the below example.How to modify the query?
Ex
Level max(level) id
1 5 101
1 5 102
1 5 103
2 5 104
2 5 105
3 5 107
4 5 120
5 5 134
5 5 280
SELECT DISTINCT level lvl
,form_frms.emp_id
,form_frms.ing_emp_id
,form_frms.prve_id
,CASE
WHEN (select div_dn
from epm_prod epm
where epm.emp_id= form_frms.ing_emp_id) ='Y' THEN DIV_DN
WHEN NVL((select distinct 'N'
from emp_pro_version prvv
where prvv.is_py='Y' and
prvv.IS_VERSION ='N' and
prvv.emp_id=form_frms.ing_emp_id) ,'Y')='N'
THEN 'Y'
WHEN NVL((select distinct 'Y'
from employee epm
where emp.emp_id=form_frms.ing_emp_id
and epm.status<>'NEW') ,'N') ='Y'
THEN 'Y'
ELSE 'N'
END
ELSE 'N'
END UN_KNOWN_ID
FROM (SELECT empvv1.prvv_id
FROM emp_view_version empvv1
WHERE empvv1.is_version = 'Y'
) form_frms
START WITH form_frms.emp_id = :lv_emp_id
CONNECT BY PRIOR form_frms.ing_emp_id = form_frms.emp_id
ORDER BY level DESC, form_frms.emp_id,UNKNOWN_ID ASC;
Edited by: shivasha on Feb 9, 2013 12:24 AM
Maybe
select lvl,
max(lvl) over (order by null rows between unbounded preceding and unbounded following) max_level,
emp_id,
unknown_id
from (SELECT DISTINCT
level lvl,
form_frms.emp_id,
form_frms.ing_emp_id,
form_frms.prve_id,
CASE WHEN (select div_dn
from epm_prod epm
where epm.emp_id = form_frms.ing_emp_id
) = 'Y'
THEN DIV_DN
WHEN NVL((select distinct 'N'
from emp_pro_version prvv
where prvv.is_py = 'Y'
and prvv.IS_VERSION = 'N'
and prvv.emp_id=form_frms.ing_emp_id
),'Y'
) = 'N'
THEN 'Y'
WHEN NVL((select distinct 'Y'
from employee epm
where emp.emp_id = form_frms.ing_emp_id
and epm.status != 'NEW'
),'N'
) = 'Y'
THEN 'Y'
ELSE 'N'
END UNKNOWN_ID
FROM (SELECT empvv1.prvv_id
FROM emp_view_version empvv1
WHERE empvv1.is_version = 'Y'
) form_frms
START WITH form_frms.emp_id = :lv_emp_id
CONNECT BY PRIOR form_frms.ing_emp_id = form_frms.emp_id
ORDER BY lvl DESC,emp_id,UNKNOWN_IDRegards
Etbin
Similar Messages
-
How to get the max value of a set of percentage values?
Hi,
I've tried to get the max and min value of a set of calculated percentage values. Such as
Jan Feb March Apr May Jun Min Average Max
0,5 0,8 1,1 0,4 1 0,6 0,4 0,7 1,1
The average value works fine. But with "min" and "max" I have a problem.
I've tried to get the value with the following ways:
- Create a new calc. keyfigure and make a sum of all values: (Jan + Feb + ...) and set the calculation in key figure properties to Min/Max.
- Create a new calc. keyfigure and make a sum of all values and set the aggregation to Min/Max
- Create a selected keyfigure with a filter to the necessary periods and set a calculation to Min (Aggregation is not possible here)
- Create a new cal. keyfigure with all periods and the function Min. e.g. min(Jan, (min Feb, (min (....)
None of this solutions provides the right min and max value. When I use an amount value (e.g. Euro) instead of these percentage values the keyfigure with the min and max function works. The others all provide wrong values.
Is there a solution to get the right min and max value???
It would be a great help when you have any hints.
Thanks
ClaudiaHi Aduri,
thanks for your answer but your solution doesn't work.
The problem is that the periods are defined in a structure with offsets such as
- period-11
- period-10
- period
in this structure elements there is also the keyfigure "netvalue" defined.
In the rows of the report there is another characteristic such as company code.
Is there a solution to find the max and min values of the period values for each company code? Or must I change the data model e.g. copy the keyfigure and make a new keyfigure with another aggregation level?
Thanks for any hints!
Claudia -
Bom explosion how to get the least level every stufe = 1
material number : 2t67363633
following is the bom of that materials
the below ouput is i got it from cs12
.1 010 6631030681
..2 010 INL025000650
..2 020 IN6631030681
.1 020 6650002622
..2 010 950002621GV
.1 030 6682500491
.1 040 712758079
but in cs13 the following output i got only the following for the same materials
.1 010 6631030681
..2 010 INL025000650 -
i got this
..2 020 IN6631030681 -
i got this
.1 020 6650002622
..2 010 950002621GV -
i got this
.1 030 6682500491 -
i got this
.1 040 712758079 -
i got this
requirement is take the least items in every level1 items
supouse if the level1 item doesnt have any subitems ,we ll take this one also
following is the detiails for the senario,using this to restrict and how to get the cs13 above output
level fld2 fld3 fld4 fld5 fld6 fld7 componentname
.1 0000001 00000097 001 00002 0001 010 6631030681 -
..2 0000001 00000093 002 00002 0001 010 inl025000650
..2 0000002 00000093 002 00004 0002 020 in6631030681-1560
.1 0000002 00000097 001 00004 0002 020 6650002622
..2 0000001 00000095 002 00002 0001 010 950002621gv
.1 0000003 00000097 001 00006 0003 030 6682500491
<b> .1 0000004 00000097 001 00008 0004 040 712758079</b>
i here attached my code for ur review
i got the output without the last leve i bold it. is there any logic to solve the problem
TABLES : MAST.
DATA: BEGIN OF ISTPO OCCURS 1000.
INCLUDE STRUCTURE STPOX.
DATA: END OF ISTPO.
DATA: W_TOPMAT LIKE CSTMAT.
SELECT-OPTIONS : P_MATNR FOR MAST-MATNR.
PARAMETERS : P_WERKS TYPE MAST-WERKS.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MAST-MATNR,
WERKS LIKE MAST-WERKS,
END OF ITAB.
DATA: IT_STB LIKE ISTPO OCCURS 0 WITH HEADER LINE.
data : istpofinal like istpo occurs 0 with header line.
data : istpotemp like istpo occurs 0 with header line.
START-OF-SELECTION.
CLEAR ISTPO. REFRESH ISTPO.
SELECT MATNR WERKS FROM MAST INTO TABLE ITAB
WHERE MATNR IN P_MATNR AND WERKS = P_WERKS.
LOOP AT ITAB.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = 'PP01'
MEHRS = 'X'
MMAPS = ' '
MDMPS = ' '
BREMS = 'X'
DATUV = SY-DATUM
MTNRV = ITAB-MATNR
WERKS = P_WERKS
EMENG = '1'
STKKZ = ' '
FBSTP = ' '
FTREL = ' '
IMPORTING
TOPMAT = W_TOPMAT
TABLES
STB = ISTPO
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
OTHERS = 8.
IF SY-SUBRC = 0.
WRITE:/ 'MaterialNumber' ,21 'Description'.
SKIP 1.
endif.
WRITE: / W_TOPMAT-MATNR UNDER TEXT-H00 COLOR COL_HEADING,
W_TOPMAT-MAKTX UNDER TEXT-H01 COLOR COL_HEADING.
data : ttabix like sy-tabix,
tstufe like stpox-stufe.
data : len type i.
istpotemp[] = istpo[].
describe table istpotemp lines len.
LOOP AT ISTPO .
WRITE :/ ISTPO-STPOZ,
ISTPO-STLKN,
ISTPO-POSNR,
ISTPO-IDNRK,
ISTPO-OJTXP,
ISTPO-MENGE,
ISTPO-MEINS.
if sy-tabix = len.
move-corresponding istpo to istpofinal.
append istpofinal.
exit.
endif.
ttabix = sy-tabix - 1 .
if tstufe ge istpo-stufe.
read table istpotemp index ttabix.
move-corresponding istpotemp to istpofinal.
append istpofinal.
endif.
tstufe = istpo-stufe.
ENDLOOP.
*endif.
endloop.
skip 3.
loop at istpofinal.
WRITE :/ ISTPOFINAL-STPOZ,
ISTPOFINAL-STLKN,
ISTPOFINAL-POSNR,
ISTPOFINAL-IDNRK,
ISTPOFINAL-OJTXP,
ISTPOFINAL-MENGE,
ISTPOFINAL-MEINS.
endloop.Hi Shiba,
We got the required list,
But while using select-option to view multiple values the list of datas in the ISTPOFINAL gets displayed like the given below.
example
Material1
.........Component 1
.........Component 2
Material 2
.........Component 1......... From Material 1
.........Component 2......... From Material 1
.........Component 3
.........Component 4
Material 3
.........Component 1......... From Material 1
.........Component 2......... From Material 1
.........Component 3......... From Material 2
.........Component 4......... From Material 2
.........Component 5
.........Component 6
Like this it goes on for the entire list at the tie of displaying the ISTPOFINAL.
We tried evn by deleting the adjacent duplicate values still it gets displayed.
is there any problm with the loop or is it the problm with the ending of the loop.
Pls suggest us.
LOOP AT ITAB.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = 'PP01'
MEHRS = 'X'
MMAPS = ' '
MDMPS = ' '
BREMS = 'X'
DATUV = SY-DATUM
MTNRV = ITAB-MATNR
WERKS = P_WERKS
EMENG = '1'
STKKZ = ' '
FBSTP = ' '
FTREL = ' '
IMPORTING
TOPMAT = W_TOPMAT
TABLES
STB = ISTPO
MATCAT = MATCAT
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
OTHERS = 8.
WRITE: / W_TOPMAT-MATNR UNDER TEXT-H00 COLOR COL_HEADING,
W_TOPMAT-MAKTX UNDER TEXT-H01 COLOR COL_HEADING.
data : ttabix like sy-tabix,
tstufe like stpox-stufe.
data : len type i.
istpotemp[] = istpo[].
describe table istpotemp lines len.
loop at istpo.
CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
EXPORTING
CAPID = 'PP01'
MEHRS = 'X'
MMAPS = ' '
MDMPS = ' '
BREMS = 'X'
DATUV = SY-DATUM
MTNRV = ISTPO-IDNRK
WERKS = P_WERKS
EMENG = '1'
STKKZ = ' '
FBSTP = ' '
FTREL = ' '
IMPORTING
TOPMAT = W_TOPMAT
TABLES
STB = ISTPOTEMP
MATCAT = MATCAT
EXCEPTIONS
ALT_NOT_FOUND = 1
CALL_INVALID = 2
MATERIAL_NOT_FOUND = 3
MISSING_AUTHORIZATION = 4
NO_BOM_FOUND = 5
NO_PLANT_DATA = 6
NO_SUITABLE_BOM_FOUND = 7
OTHERS = 8.
if sy-subrc ne 0.
move-corresponding istpo to istpofinal.
append istpofinal.
clear: istpo, istpofinal.
else.
continue.
clear: istpo, istpofinal.
endif.
*break-point.
delete adjacent duplicates from istpofinal.
endloop.
loop at istpofinal.
WRITE :/ ISTPOFINAL-STPOZ,
ISTPOFINAL-STLKN,
ISTPOFINAL-POSNR,
ISTPOFINAL-IDNRK,
ISTPOFINAL-OJTXP,
ISTPOFINAL-MENGE,
ISTPOFINAL-MEINS.
clear: istpofinal.
endloop.
endloop. -
How to get the domain level values in web ui pick list
Hi Gurus,
I was added one field through EEWB transaction and i was maintained the values in domain level.now my requirement is i was added this field in web ui.but i don't know how to get the values which are we maitained in domain level. pls send me the solution it is very needful for me..
Regards,
Bixamaiah.BHi Bussa,
Refer to the documentation on drop-down Boxes in UI here:
CRM Web Client UI Framework [original link is broken]
This should help you, but do get back if you face any issues in implementing the same.
Regards,
Padma Guda -
how to get the record with the max sequence no
table as
seq student mark
1 A 10
2 A 15
1 B 20
2 B 10
1 C 30
here is what i need
seq student mark
2 A 15
2 B 10
1 C 30i have used your query + some decode
With t As
Select 'A' st, 'X' Type, 1 seq, 001 marker_no, 10 mark From dual Union All
Select 'A', 'X', 2, 001, 12 From dual Union All
Select 'B', 'X', 1, 002, 10 From dual Union All
Select 'B', 'X', 2, 003, 12 From dual Union All
Select 'B', 'X', 3, 003, 15 From dual Union All
Select 'C', 'X', 1, 001, 10 From dual Union All
Select 'C', 'X', 2, 002, 15 From dual Union All
Select 'C', 'Y', 3, 001, 20 From dual Union All
Select 'C', 'Y', 4, 001, 10 From dual
Select st,
Sum (x_cnt) x_cnt,
Max (x_seq) Keep (dense_rank Last Order By x_seq) x_seq,
max(x_marker_no) keep(dense_rank last order by x_seq) x_marker_no,
max(x_mark) keep(dense_rank last order by x_seq) x_mark,
sum(y_cnt) y_cnt,
max(y_seq) keep(dense_rank last order by y_seq) y_seq,
max(y_marker_no) keep(dense_rank last order by y_seq) y_marker_no,
max(y_mark) keep(dense_rank last order by y_seq) y_mark
from
(Select st,
decode(Type ,'X',1,0) x_cnt,
decode(type ,'X',seq,0) x_seq,
decode(Type ,'X',marker_no,0) x_marker_no,
decode(Type ,'X',mark,0) x_mark,
decode(Type ,'Y',1,0) y_cnt,
decode(Type ,'Y',seq,0) y_seq,
decode(Type ,'Y',marker_no,0) y_marker_no,
decode(Type ,'Y',mark,0) y_mark
From t
Group By st;
/*this is the output
st X_cnt X_seq X_marker_no X_mark Y_cnt Y_seq Y_marker_no Y_mark
A 2 2 001 12 0 null null null
B 3 3 003 15 0 null null null
C 2 2 002 15 2 4 001 10
ST X_CNT X_SEQ X_MARKER_NO X_MARK Y_CNT Y_SEQ Y_MARKER_NO Y_MARK
A 2 2 1 12 0 0 0 0
B 3 3 3 15 0 0 0 0
C 2 2 2 15 2 4 1 10 -
How to get the inheritance level for an atribute value
hi,
i have to get the inheritance level for an attribute value for a given user in Org.struc.Hi,
Check out table T77OMATTUS for inheritance level for an attributes
Regards,
Neelima -
How to get the max value in the query??
Plant calday(mm.dd.yyyy) Soldout.Qty
0001 01.01.2005 10
0001 01.02.2005 20
0001 01.03.2005 05
0001 01.04.2005 16
0001 01.05.2005 10
0001 01.06.2005 14
From the above values , how can i findout Max(Soldout.Qty)(i.e 20) for the above week...Suppose present aggregation = summation...How can i findout the value in the Query??don't want to do changes to design...Hi Bhanu,
I tried the calculation results as...Maximum,..
But that will pick the maximum value among the avialable values..like
plant1 max 10
plant2 max 20
plant3 max 30
then it will show as..
plant1 max 30
plant2 max 30
...like this...but my case is
plant1 calday1 10
plant1 calday2 05
plan1 calday7 08
plant2 calday1 10
plant2 calday2 05
plan2 calday7 20
so for each set it need to bring the maximum value... -
HOw to Get the top level of Hierarchy and count on that basis
hi
i have following tables
desc hr_organizations_units_V
organization_id PRIMARY KEY
name
ORGANIZATION_type
per_org_structure_elements
organization_id_parent FK TO hr_organizations_units_V(ORGANIZATION_ID)
organization_id_child FK TO hr_organizations_units_V(ORGANIZATION_ID)
I HAVE THIS QUERY TO GET PARENT CHILD
SELECT ORGANIZATION_ID_PARENT PARENT,ORGANIZATION_ID_CHILD CHILD,ORGANIZATION_TYPE FROM PER_ORG_STRUCTURE_ELEMENTS OSE,HR_ALL_ORGANIZATION_UNITS AOU WHERE AOU.ORGANIZATION_ID = OSE.ORGANIZATION_ID_CHILD CONNECT BY PRIOR ORGANIZATION_ID_CHILD = ORGANIZATION_ID_PARENT
START WITH ORGANIZATION_ID_PARENT = 82 -- THE GRAND PARENT
ORDER BY ORGANIZATION_ID_PARENT
PARENT CHILD ORGANIZATION_TYPE
82 83 COMPANY
82 143 COMPANY
83 84 DIVISION
83 134 DEPARTMENT
83 135 DEPARTMENT
DESC per_all_assignments_f
ASSIGNMENT_NUMBER
ORGANIZATION_ID FORIGN KEY TO HR_ALL_ORGANIZATION_UNITS
THE ASSIGNMENTS ARE ASSIGNED ON DEPARTMENT LEVEL.
MY REQUIREMENT IS THAT I WANT TO GET THE
1)TOTAL NO OF ASSIGNMENTS ON THE DIVISION LEVEL
2)TOTAL NO OF ASSIGNMENTS ON THE COMPANY LEVEL
3)REPORTS LIKE PAY SLIP ETC I WANT TO GET THE ABOVE TWO LEVELS OF ORGANIZATION FOR EACH EMPLOYEE I.E DIVISION AND COMPANY OF
OF THE EMPLOYEE'S DEPARTMENT.
I WILL REALLY APPRECIATE ANY HELPING HAND.
REGARDSHere are a few ways to get what I think you are asking for now. If this is not what you want, then please provide a complete example of what you want, including sample data, and the complete query result, including numbers, based on that data, that you want, as I have done below.
scott@ORA92> -- test data:
scott@ORA92> SELECT * FROM hr_all_organization_units
2 /
ORGANIZATION_ID NAME ORGANIZATIO
82 GRANDPARENT GRANDPARENT
83 COMPANY 83 COMPANY
84 DIVISION 84 DIVISION
134 DEPARTMENT 134 DEPARTMENT
135 DEPARTMENT 135 DEPARTMENT
143 COMPANY 143 COMPANY
6 rows selected.
scott@ORA92> SELECT * FROM per_org_structure_elements
2 /
ORGANIZATION_ID_PARENT ORGANIZATION_ID_CHILD
82 83
82 143
83 84
84 134
84 135
scott@ORA92> SELECT * FROM per_all_assignments_f
2 /
ASSIGNMENT_NUMBER ORGANIZATION_ID
1 83
2 84
3 134
4 135
5 143
6 84
6 rows selected.
scott@ORA92> -- method 1:
scott@ORA92> COLUMN name FORMAT A35
scott@ORA92> SELECT RPAD ('.', 5 * (LEVEL - 1), '.') || aou.name AS name,
2 (SELECT SUM (the_count)
3 FROM (SELECT organization_id_parent,
4 organization_id_child,
5 COUNT (*) AS the_count
6 FROM per_org_structure_elements,
7 per_all_assignments_f
8 WHERE per_org_structure_elements.organization_id_child =
9 per_all_assignments_f.organization_id
10 GROUP BY organization_id_parent,
11 organization_id_child) t
12 START WITH t.organization_id_child =
13 ose.organization_id_child
14 CONNECT BY PRIOR t.organization_id_child =
15 t.organization_id_parent) AS assignments_count
16 FROM PER_ORG_STRUCTURE_ELEMENTS OSE,
17 HR_ALL_ORGANIZATION_UNITS AOU
18 WHERE AOU.ORGANIZATION_ID = OSE.ORGANIZATION_ID_CHILD
19 START WITH aou.name = '&company_name'
20 CONNECT BY PRIOR ose.ORGANIZATION_ID_CHILD = ose.ORGANIZATION_ID_PARENT
21 /
Enter value for company_name: COMPANY 83
old 19: START WITH aou.name = '&company_name'
new 19: START WITH aou.name = 'COMPANY 83'
NAME ASSIGNMENTS_COUNT
COMPANY 83 5
.....DIVISION 84 4
..........DEPARTMENT 134 1
..........DEPARTMENT 135 1
scott@ORA92> -- method 2:
scott@ORA92> COLUMN name FORMAT A35
scott@ORA92> WITH sub_query AS
2 (SELECT ose.organization_id_parent, ose.organization_id_child,
3 aou.name, COUNT (*) AS assignments
4 FROM per_org_structure_elements ose,
5 hr_all_organization_units aou,
6 per_all_assignments_f aaf
7 WHERE ose.organization_id_child = aou.organization_id
8 AND ose.organization_id_child = aaf.organization_id
9 AND aou.organization_id = aaf.organization_id
10 GROUP BY ose.organization_id_parent, ose.organization_id_child, aou.name)
11 SELECT RPAD ('.', 5 * (LEVEL - 1), '.') || name AS name,
12 (select SUM (assignments)
13 from sub_query
14 start with organization_id_child = t.organization_id_child
15 connect by prior organization_id_child = organization_id_parent)
16 AS assignments_count
17 FROM sub_query t
18 START WITH name = '&company_name'
19 CONNECT BY PRIOR ORGANIZATION_ID_CHILD = ORGANIZATION_ID_PARENT
20 /
Enter value for company_name: COMPANY 83
old 18: START WITH name = '&company_name'
new 18: START WITH name = 'COMPANY 83'
NAME ASSIGNMENTS_COUNT
COMPANY 83 5
.....DIVISION 84 4
..........DEPARTMENT 134 1
..........DEPARTMENT 135 1
scott@ORA92> -- method 3:
scott@ORA92> COLUMN name FORMAT A35
scott@ORA92> CREATE OR REPLACE VIEW sub_query AS
2 SELECT ose.organization_id_parent, ose.organization_id_child,
3 aou.name, COUNT (*) AS assignments
4 FROM per_org_structure_elements ose,
5 hr_all_organization_units aou,
6 per_all_assignments_f aaf
7 WHERE ose.organization_id_child = aou.organization_id
8 AND ose.organization_id_child = aaf.organization_id
9 AND aou.organization_id = aaf.organization_id
10 GROUP BY ose.organization_id_parent, ose.organization_id_child, aou.name
11 /
View created.
scott@ORA92> SELECT RPAD ('.', 5 * (LEVEL - 1), '.') || name AS name,
2 (select SUM (assignments)
3 from sub_query
4 start with organization_id_child = t.organization_id_child
5 connect by prior organization_id_child = organization_id_parent)
6 AS assignments_count
7 FROM sub_query t
8 START WITH name = '&company_name'
9 CONNECT BY PRIOR ORGANIZATION_ID_CHILD = ORGANIZATION_ID_PARENT
10 /
Enter value for company_name: COMPANY 83
old 8: START WITH name = '&company_name'
new 8: START WITH name = 'COMPANY 83'
NAME ASSIGNMENTS_COUNT
COMPANY 83 5
.....DIVISION 84 4
..........DEPARTMENT 134 1
..........DEPARTMENT 135 1 -
How to get the Max value of elements of type datetime
Hi All ,
I wanted to get the latest timestamp value ( datatype as datetime) from node list. I have following xml. In this xml, i want to get the modifydate element which has latest timestamp through xquery/xpath, it should return me following result 2011-09-29T17:21:17+10:00
<CustomerList>
<CustomerDetails>
<name> Test 1</name>
<status>active</status>
<modifyDate>2011-08-20T17:21:17+10:00</modifyDate>
</CustomerDetails>
<CustomerDetails>
<name> Test 2</name>
<status>cancel</status>
<modifyDate>2011-08-29T17:21:17+10:00</modifyDate>
</CustomerDetails>
<CustomerDetails>
<name> Test 3</name>
<status>active</status>
<modifyDate>2011-09-29T17:21:17+10:00</modifyDate>
</CustomerDetails>
</CustomerList>
i tried to use the
//CustomerList/CustomerDetails/modifyDate[not(. <=../preceding-sibling::CustomerList/CustomerDetails/modifyDate) and not(. <=../following-sibling::CustomerList/CustomerDetails/modifyDate)]
But it is not working on datetime datatype.
Any help in this regard is much appreciated.
Regards
Edited by: user6736659 on Sep 5, 2011 6:15 AMHi,
The following XQuery should give you what you want :
max(
for $i in /CustomerList/CustomerDetails/modifyDate
return xs:dateTime($i)
)For instance, using Oracle SQL :
SQL> var xmldoc varchar2(4000)
SQL> begin
2 :xmldoc := '<CustomerList>
3 <CustomerDetails>
4 <name> Test 1</name>
5 <status>active</status>
6 <modifyDate>2011-08-20T17:21:17+10:00</modifyDate>
7 </CustomerDetails>
8
9 <CustomerDetails>
10 <name> Test 2</name>
11 <status>cancel</status>
12 <modifyDate>2011-08-29T17:21:17+10:00</modifyDate>
13 </CustomerDetails>
14
15 <CustomerDetails>
16 <name> Test 3</name>
17 <status>active</status>
18 <modifyDate>2011-09-29T17:21:17+10:00</modifyDate>
19 </CustomerDetails>
20 </CustomerList>';
21 end;
22 /
PL/SQL procedure successfully completed
SQL> select xmlquery('max(
2 for $i in /CustomerList/CustomerDetails/modifyDate
3 return xs:dateTime($i)
4 )'
5 passing xmltype(:xmldoc)
6 returning content
7 )
8 from dual
9 ;
XMLQUERY('MAX(FOR$IIN/CUSTOMER
2011-09-29T17:21:17.000000+10:00 -
How to get the max total sale by date on every store
I am trying to write a query in Oracle which will return both the store_id and the maximum total sale by date
Hi,
Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002#9362002
Hjava wrote:
I am trying to write a query in Oracle which will return both the store_id and the maximum total sale by date
Do you mean you want to see the store_id that had the maximum total sale?
In general, this can be done with a Top-N Query, using an analytic function such as RANK. For an example, see http://forums.oracle.com/forums/thread.jspa?messageID=3739610
If you only want the date, the maximum total from that date, and 1 column from the same row with the maximum (e.g. store_id), then you might be able to use the aggregate LAST function instead.
What results do you want in case of a tie? (That is, if 2 or mote store_ids have the same total sale on a given date, and no other store_id has a higher total.) -
How to get the max. and min. of a selection-option?
hi experters
I wonder if there is any way can fetch the max value and minimum value from a select-option?
please hint, many thanks
wanlei.suna®s wrote:
> Try this way
>
>
> SELECT-OPTIONS S_WERKS FOR T001W-WERKS.
>
> START-OF-SELECTION.
> SELECT * FROM T001W INTO IT_T001W
> WHERE WERKS IN S_WERKS.
>
> SORT IT_T001W BY WERKS ASCENDING.
> READ TABLE IT_T001W INDEX 1.
> MOVE IT_T001W-WERKS TO V_WERKS_MIN. " MIN Value
>
> SORT IT_T001W BY WERKS DESCENDING.
> READ TABLE IT_T001W INDEX 1.
> MOVE IT_T001W-WERKS TO V_WERKS_MAX. " MAx Value
>
>
> a®s
Please try this.
TABLES : t001w.
SELECT-OPTIONS S_WERKS FOR T001W-WERKS.
data: lv_min type T001W-WERKS,
lv_max type T001W-WERKS,
lv_count type i.
START-OF-SELECTION.
sort s_werks by low.
describe TABLE s_werks LINES lv_count.
if lv_count = 1.
lv_min = s_werks-low.
lv_max = s_werks-high.
elseif lv_count > 1.
read TABLE s_werks index 1.
lv_min = s_werks-low.
if not s_werks-high is INITIAL.
lv_max = s_werks-high.
endif.
READ TABLE s_werks INDEX lv_count.
if lv_max is INITIAL.
lv_max = s_werks-low.
else.
if lv_max < s_werks-low.
lv_max = s_werks-low.
endif.
endif.
endif.
write :/ lv_min,
lv_max. -
How to get the MAX,MIN from the below table...
Hi,
Database is SQL2012 R2 Express and I have a table and would like to dig out the MAX,MIN value of a specifiied date (e.g 2014-11-03)
ThanksNope... It still output more than 1 value on the same date...
DL-01-BAT 13.00753 13.00753 10/10/2014
DL-01-BAT 13.01342 13.01342 10/10/2014
DL-01-BAT 13.02706 13.02706 10/10/2014
DL-01-BAT 13.03485 13.03485 10/10/2014
Raw data is
DL-01-BAT 13.00753 13.00753 10/10/2014 20:00
DL-01-BAT 13.01342 13.01342 10/10/2014 21:00
DL-01-BAT 13.02706 13.02706 10/10/2014 22:00
DL-01-BAT 13.03485 13.03485 10/10/2014 23:00
You mean after applying my suggestion?
I dont think so
See illustration below
declare @t table
Item VARCHAR(10), Reading VarChar(50),DateTimeReading DATETIME)
INSERT @t
VALUES
('DL-01-BAT', 13.00753,'10/10/2014 20:00'),
('DL-01-BAT', 13.01342,'10/10/2014 21:00'),
('DL-01-BAT', 13.02706,'10/10/2014 22:00'),
('DL-01-BAT', 13.03485,'10/10/2014 23:00')
DECLARE @Date datetime = '20141010'
SELECT Item,
MAX(Reading) AS [Max],
MIN(Reading) AS [Min],
DATEADD(dd,DATEDIFF(dd,0,DateTimeReading),0) AS [Date]
FROM @t
WHERE DateTimeReading >= @Date
AND DateTimeReading < DATEADD(dd,1,@Date)
GROUP BY Item, DATEADD(dd,DATEDIFF(dd,0,DateTimeReading),0)
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
How to get the max P2P avlue of a signal
Hello!
I'm very new to the whole LabView program, and have some issues with very basic need I have to apply to my program.
I need to measure the max P2P of a signal and preform some analysis on that, the problem is that the Amplitude and measurments VI gives me the P2P at every given sample. Is there any way for doing this right?
Thank you
Solved!
Go to Solution.You can store it in a shift register.
A shift register is one of those basic elements of LabVIEW that you must become familiar with. Have you taken any of the tutorials?
Message Edited by Dennis Knutson on 02-03-2010 10:52 PM
Attachments:
Keep Max.PNG 3 KB -
How to get the Table Level Constraints List
hi all,
i created a table as follows,
create table temp(fld1 number, fld2 number, fld3 varchar2(10),
constraint fld1_pk primary key (fld1),
constraint fld2_uk unique (fld2) );
table has created successfully.
now i need to get list of constraints (constraint_names) in to Java.
i checked user_tab_columns table and in that i got only nullable.
how to get this one, with query;
regards
pavanYes!
SQL> select constraint_name, generated from user_constraints
2 where table_name = 'EMP'
3 /
CONSTRAINT_NAME GENERATED
SYS_C003996 GENERATED NAME
SYS_C003997 GENERATED NAME
EMP_PRIMARY_KEY USER NAME
EMP_SELF_KEY USER NAME
EMP_FOREIGN_KEY USER NAME
5 rows selected.
SQL>Cheers
Sarma.
Message was edited by:
Radhakrishna Sarma -
How we get the lower level employee under particular level employee
Hi ,
i have query like
select lpad(' ', 3*level) || empno, level
from
scott.emp
start with
mgr is null
connect by
prior empno=mgr
output:-
LPAD('',3*LEVEL)||EMPNO LEVEL
7839 1
7566 2
7788 3
7876 4
7902 3
7369 4
7698 2
7499 3
7521 3
7654 3
7844 3
7900 3
7782 2
7934 3
i want to get all hierarchy under particular employee id i entered during runtime. eg. if i entered 7566 then it should display the following output.
7566 2
7788 3
7876 4
7902 3
7369 4
is it possible , please suggest.
thanks
kamHello,
How about trying like this?
SELECT LPAD(' ', 3*LEVEL) || empno, LEVEL
FROM scott.emp
START WITH empno=7566 -- Or any value from where you want to start
CONNECT BY PRIOR empno=mgr -Ammad
Maybe you are looking for
-
Email a Report to Customer in AR
Hi, I have a requirement to send an email of report to the customer while i run the concurrent program. It is not an XML report. Please advise me to do. Thanks in Advance, Pradeep Edited by: user11165897 on Dec 7, 2012 1:27 AM
-
RFC error for Transaction Launcher to launch a CRM ABAP report on WEB UI
Hi all, My Task is to assign a custom CRM report on the web ui. I have created a transaction for this and using the transaction launcher wizard to assign it as a link on web ui . In the transaction launcher wizard , In the 'Define Further Technical
-
I had to reset my phone and now when I text my contacts are not showing up
I had to reset my phone and now when I send and receive text messages it is not showing the contact name only the phone number. Help.
-
Can anyone please tell me why the 'Name' part of the form on this page doesnt show in the email that i recieve when a visitor submits the form. www.milesmemorials.com/request.html the php file for this form is: <?php if(!isset($_POST['submit']))
-
How to differentiate a dimension single slect or multi-select
Hi, I am trying to seperate out the dimensions list based on whether its a multi-select dimension or a normal one, beacause I want to display all multi-select (facets) dimensions at bottem and normal dimension for navigation at the top. Is there any