Oracle: how to use the max() function in expression box
How to use the max() function in the case where expression, please explain with an exampleHope this helps and should be explicit
with t as
(select 1 col,100 col2 from dual union
select 2 ,100 from dual union
select 2 ,200 from dual union
select 3,100 from dual union
select 3,200 from dual )
select col, case when max(col2)=100 then 'with 100 range'
when max(col2)=200 then 'with 200 range' end from t group by col
Tags: Database
Similar Questions
-
How to use the @accum function in the calculation script
Dear all.
I'm new in essbase - calculation script so don't know how to use the @accum function.
I want the aggregation value of child to parent
Hierarchy
Product
100 > Storage Dimensions marked as stored (marked as intentionally as I want to calculate the value using the calculation script)
100. 10 (+)
100-20 (+)
100-30 (+)
I'm trying calculation Script
100 = @Accum (@children("100"), jan: Feb);
It works when I use below
100 = @Accum("100-10",Jan:Feb);
Error:-number of Dimensions [1] does not match number of gen/lev [3] office [@Dim]
Don't know how I can roll up to an aggregate value of all the members of the child to the parent.
you do this more difficult it must be. If you want to accumulate up to 100 then you could just make your calc
'100 '.
but that would be only 100, to make the OU any dimension would
AGG (Product);
Or better yet
AGG (Product, Market);
-
How to use the NVL function in decoding?
Hi all
How to use the NVL function in decoding?
SELECT Decode (Sign (sum (nvl (7), 0)-nvl (sum (5), 0)), - 1, 0, (sum (nvl (7), 0)-nvl (sum (5), 0)) QTY)
of the double
Thank you
You should not do that...
Greatest (NVL (Sum (Quantity), 0)-NVL (SUM (quantity_received), 0), 0) AS qty_arrival
will do the same
HTH
-
How to use the goto function?
How to use the goto function in indesign javascript?
my script begins by chekcing if the input files are present or not... If one of the input files is not present, I want the n function put an end to the operation in the display of the message tht file exists... I was wondering to use goto for tht... then how to use it? or is there an alternative to that?
GoTo is generally frowned upon by the programmers.
The only legitimate use of goto is when you need to escape from a nested loop.
If you need to jump into a routine, use break or simply in return from the current function.
The model currently used by the SDK looks like this:
do { if(condition1 == false) break; if(condition2 == false) break; if(condition3 == false) break; doSomethingReallyCool(); }while(false);
'break' the jumps at the end of the do / while loop that always comes out when you reach the end of it (while (false))
Substances
-
How to use the TRUNC function with dates in the expression builder in OBIEE.
Hello
How to use the TRUNC function with dates in the expression builder in OBIEE.
TRUNC (SYSDATE, 'MM') returns 1 July 2010"where sysdate is July 15, 2010 ' in SQL. I need to use the same in the expression builder in the logical layer mdb column.
Thanks in advanceUse it instead:
TIMESTAMPADD (SQL_TSI_DAY, (DAYOFMONTH (CURRENT_DATE) *-1) + 1, CURRENT_DATE) -
How to use the add_months() function in a mapping?
Hello
I have a variable in ODI with a date and I need to add another variable to add 'x' months...
How can do that?
Thank you
If you say you have variable1 organise a date for example 01/01/2015 and variable 2 holding a certain number of months for example 7?
If so in your mapping expression simply use the date functions available to your database technology (step/target) and replace the variable in the function
that is for Oracle your mapping would be ADD_MONTHS (#Variable1,Variable2of #)
-
How to use the NVL function to a parameter with comma delimited values
Gurus,
It is confusing to me. I am trying to use the NVL function, but the setting that I'm passing in my cursor contains multiple values with commas. The NVL function is confused when analyzing the values.
'Where' cursor clause...
and nvl (sn.c_attribute1,'x@#$%') in nvl (p_desig,'x@#$%'( )
translated parameter values...
and nvl (sn.c_attribute1,'x@#$%') in nvl ('SPRT''GOOD' 'BAD' 'x@#$%') -NVL does not parse the value correctly
Any idea on how to get NVL recognize 'x@#$%' , if p_desig is null?
Thank you
Scott
HI, Scott.
Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
My best guess, based on what you posted bone is present, that your problem is discussed in the following:
-
How to use the Substring function with Case statement.
Hi all
I have a requirement where I have to use the substring function on the ground for the report criteria.
FOR EXAMPLE
I branch domain name where I have all the information of the branch names, now some of the branch names are too large with an extension after the name.
now I want substing it, but the length of characters varies for each branch.
so is it possible where we use a box where we can define if the character of name plug exceed a value then he substing with this length.Try something like this:
LENGTH WHEN CARTER (tablename. Branch_Name) > n THEN SUBSTRING (...) Of ANOTHER tablename. Branch_Name END
where n is the number of characters that you want to start the break.
-
How to use the Pivot function for range group in oracle SQL
Hello
Hello!!!
I need to display the data in the format below. There are 2 columns 1 is State and another is rate.
State < 100 100-199, 200-299 300-399 400-499, 500-599 600-699 700-799 800-899 900-999 > = 1000 Total
AK 1 2 0 4 1 4 4 35 35 4 1 25
AL 0 0 2 27 10 17 35 2 2 35 0 103
AR 0 0 1 0 0 2 2 13 13 2 0 6
AZ 0 1 2 14 2 14 13 3 3 13 0 57
CA 0 0 1 6 2 7 3 4 4 3 0 34
Developed the sub query but unable to use the beach on the pivot function. Please help on this.
(select (SELECT short_description
OF CODE_VALUES
WHERE CODE_TYPE_CODE = ad. STATE_TYPE_IND_CODE
AND VALUE = ad. STATE_CODE
) STATE,
Nr.rate
N-NEUTRAL
c contacts,
announcement of addresses,
xref_contacts_addresses xca,
neutral_rates nr
where n.contact_id = c.contact_id
and n.address_id = ad.address_id
and xca.address_id = ad.address_id
and xca.contact_id = c.contact_id
and nr.contact_id = n.contact_id
and nr.rate_frequency = 'HOUR')Like this
with t as ( select 'AL' state, 12 value from dual union all select 'AL' state, 67 value from dual union all select 'AL' state, 23 value from dual union all select 'AL' state, 12 value from dual union all select 'AL' state, 12 value from dual union all select 'AL' state, 78 value from dual union all select 'AL' state, 34 value from dual union all select 'AL' state, 4 value from dual union all select 'AL' state, 12 value from dual union all select 'AL' state, 15 value from dual union all select 'AZ' state, 6 value from dual union all select 'AZ' state, 123 value from dual union all select 'AZ' state, 123 value from dual union all select 'MA' state, 23 value from dual union all select 'MA' state, 120 value from dual union all select 'MA' state, 456 value from dual union all select 'MA' state, 11 value from dual union all select 'MA' state, 24 value from dual union all select 'MA' state, 34 value from dual union all select 'MA' state, 87 value from dual union all select 'MA' state, 23 value from dual union all select 'MA' state, 234 value from dual union all select 'MA' state, 789 value from dual union all select 'MH' state, 54321 value from dual ) -- End of test data select state, nvl(count(decode(value, 0, 0)), 0) "<100", nvl(count(decode(value, 1, 1)), 0) "100-199", nvl(count(decode(value, 2, 2)), 0) "200-299", nvl(count(decode(value, 3, 3)), 0) "300-399", nvl(count(decode(value, 4, 4)), 0) "400-499", nvl(count(decode(value, 5, 5)), 0) "500-599", nvl(count(decode(value, 6, 6)), 0) "600-699", nvl(count(decode(value, 7, 7)), 0) "700-799", nvl(count(decode(value, 8, 8)), 0) "800-899", nvl(count(decode(value, 9, 9)), 0) "900-999", nvl(count(decode(value, 10, 10)), 0) ">=1000" from ( select state, case when value < 100 then 0 when value between 100 and 199 then 1 when value between 200 and 299 then 2 when value between 300 and 399 then 3 when value between 400 and 499 then 4 when value between 500 and 599 then 5 when value between 600 and 699 then 6 when value between 700 and 799 then 7 when value between 800 and 899 then 8 when value between 900 and 999 then 9 when value >= 1000 then 10 end value from t ) group by state
-
How to use the node function call library for a function in the dll with the data SUB type
Hi all
I would ask for your kind help
I am facing a problem with the call library node.
I have a C++ (stdcall) function, which has Sub as data type
XXXX error code (hwnd, lid, getValue, * Sub data1, * Sub data2)
data1 and data2 types are constantly changing based on the value of 'getValue '.
Mainly I can use the call library node several times and adapt each node according to the types of data data1, data2 and extract the values and use in the code. Here is no question. Real question is:
My question:
How can I use a node of library time call and make a case according to the 'getvalue', who will control the data1, data2 data type. Here I really seeking solutions.
My tests:
I used varaints as entry to the libray call node of the data1, data2 and selected parameters in the call libraby node as "Adapt to type. Here labview just crashed.
I appreciate your suggestions to feedbackand.
Thank you
Karine
You must allocate enough space for data1 and data2, and then pass a pointer to this space. An easy way to do this is the function to initialize table. Set the U8 type and size for the number of bytes required. Pass this array to the function as a pointer of table data.
After the function call returns, you need to extract the data in the table. You can do it manually, but a simple approach is to use the array of bytes to a string. Then, in a housing structure, use Unflatten chain to convert the string to the correct data type. This method also converts the "endianness" which will be probably necessary; Be sure to only set all entries for unflatten correctly.
-
How to use the instancecount function in Excel
Hi OPA Experts,
I have under the rule of the word:
ES HL functional review has no records which no State registration is completed if
InstanceCountIf (function of hl hw customer proposal, status of the review of the hw proposal hl = "Review complete" function) = 0 and
InstanceCountIf (function of hl hw customer proposal, status of the review of the hw proposal hl = "Return" function) = 0 and
InstanceCountIf (function proposal customer hw, the review hw proposal function = "Cancelled" status) = 0
or
or the other
InstanceCountIf (function of hl hw customer proposal, status of the review of the function hw proposal hl = "Not started") > 0 or
InstanceCountIf (function of hl hw customer proposal, status of the review of the hw proposal hl = "in the journal" function) > 0 or
InstanceCountIf (function of hl hw customer proposal, status of the review of the function hw proposal hl = "awaiting updated comments") > 0 or
InstanceCountIf (function of hl hw customer proposal, status of the review of the hw proposal hl = "Returned for Reassigning reviewer" function) > 0 or
InstanceCountIf (function of hl hw customer proposal, status of the review of the function hw proposal hl = "Returned for adding/updating of Documents") > 0
Can I create a legend for (function of hl hw customer proposal, status of the review of the proposal hl hw function) and use it in excel, please give me an example.
Thank you
As a side note, you can replace "InstanceCountIf (function of hl hw customer proposal, status of the review of the hw proposal hl ="Review complete"function) = 0"
With
There are (according to hl hw customer proposal, status of the review of the hw proposal hl = "Review complete" function)
-
I'm trying to shoot 1 row for each document_id, it should be the max version, but im getting lines in double for some reason any.
----------
create the table max_test
(
'PROJECT' VARCHAR2 (50 BYTE),
"DOCUMENT_ID" VARCHAR2 (50 BYTE),
VARCHAR2 (5 BYTE) 'VERSION',
"CREATE_DATE' VARCHAR2 (DATE),
VARCHAR2 (DATE) 'UPDATE_DATE ',.
VARCAHR2 (100 BYTE) "MANAGER_NAME".
)
--------------
INSERT ALL
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 500,1, 18, March 1, 12 ', March 1, 12 ', ' BOB JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 500,2, 6, March 1, 12 ', March 1, 12 ', ' STEVE JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 500,3, 2, March 1, 12 ', March 1, 12 ', ' MIKE JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 501,4, 5, March 1, 12 ', March 1, 12 ', ' MARK JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 501,5, 1, March 1, 12 ', March 1, 12 ', ' TOM JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 502,6, 20, March 1, 12 ', March 1, 12 ', ' EVE JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 502,7, 3, March 1, 12 ', March 1, 12 ', "CHRIS JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 503,8, 1, March 1, 12 ', March 1, 12 ', ' LARRY JONES)
IN max_test (PROJECT, DOCUMENT_ID VERSION, CREATE_DATE, UDPATE_DATE, MANAGER_NAME) VALUES (' 503,9, 2, March 1, 12 ', March 1, 12 ', ' JOE JONES)
;
Select distinct (project), max (version), document_id update_date, create_date, manager_name
of max_test
Project group, document_id, create_date, update_date, manager_name
I get several lines for each project and want to only 1 row by project, 1 line which is the max versionAnd continuing my previous post, if you want to have lines only for the maybe max version that you want to write a query like this:
SELECT project, version, document_id, create_date , update_date, manager_name FROM max_test WHERE (project, version) IN ( SELECT project, MAX (version) FROM max_test GROUP BY project); PROJECT VERSION DOCUMENT_ID CREATE_DATE UPDATE_DATE MANAGER_NAME -------- ------- ------------ ----------- ----------- ------------- 500 6 2 01-MAR-12 01-MAR-12 STEVE JONES 501 5 4 01-MAR-12 01-MAR-12 MARK JONES 502 3 7 01-MAR-12 01-MAR-12 CHRIS JONES 503 2 9 01-MAR-12 01-MAR-12 JOE JONES 4 rows selected.
Kind regards.
Al -
How to use the custom function to put in shape of line chart Axes?
Hello...
I use a graphic line which the axis value is vary from 0 to 50000. It is a number which he gets from its dataProvider. I want to format it and show it as
$50,000
$40,000
$30,000
$20,000
$10,000
$0
Instead of
50000
40000
30000
20000
10000
0
Here is my code linechart:
< mx:LineChart id = "revTimeLineChart".
Width = "100%" height = "100%".
showDataTips = "true" >
< mx:horizontalAxis >
< mx:CategoryAxis id = "lcCatAxis" categoryField = "name" / >
< / mx:horizontalAxis >
< mx:series >
< mx:LineSeries id = "ls" yField = "income" displayName = "Recipes" showDataEffect = "{slideIn}" / > (yField, this is what I want to do a format...)
< / mx:series >< / mx:LineChart >
Can you please let me know how can this be achieved?
See you soon!
Deepak
Hello
you need a labelFunction in AxisRenderer.
See the example in the documentation
http://livedocs.Adobe.com/Flex/3/langref/MX/charts/AxisRenderer.html#includeExamplesSummar y
-
How to use the ratio_to_report function
Hello
I have a problem using ratio_to_report to create the following report.
I have a table MYTABLE with three columns A, B and C.
A, B AND C
1 150 positive
1 130 positive
1 110 negative
1 150 negative
1 110 negative
2 150 negative
2 110 positive
2 110 negative
...
I want to get is a report where I have a column reports the percentage of negative situations of a certain group of B value by a column.
In my case, for example, I would like to provide you a report where the new PERCENTAGE column will contain the negative of the value 150 b within Group 1 rate, then the negative of the rate of 150 in Group 2 and so on for each value of B, which is such a report:
A PERCENTAGE_NEGATIVE B
1 150 15%
1 130 30%
1 110 0%
2 150 35%
2 110 25%
Pay attention that in the report above, I have not calculated the right percentage value
Thanks in advance.Hello
Simper is not not to use RATIO_TO_REPORT for that:
SELECT a, b , COUNT ( CASE WHEN c = 'negative' THEN 1 END ) * 100 / COUNT (*) AS percentage_negative FROM mytable GROUP BY a, b ORDER BY a, b ;
You use RATIO_TO_REPORT, you could do a subquery to calculate RATIO_TO_REPORT for all values of c and then filter all except the "negative in the main query.
Mark1970 wrote:
Pay attention that in the report above, I have not calculated the right percentage valueWhy? With only 8 rows of sample data, would be easy enough to manually calculate the correct results? It would be much more useful to people who want to help you.
-
SQL query using the MAX function
I am trying to display only those records where the "date_entered" is the most recent by case number.
Right now, it's the output im get.SELECT distinct c.case_number, u.email,c.assigneddate_chart, --m.date_entered, max(m.date_entered)as last_date_entered, trunc(sysdate)-trunc(c.assigneddate_chart)days_late, trunc(sysdate)-trunc(m.date_entered)addl_days_late from chart c, chart_user_roles u,comments m where (c.case_status IN ('Open','Pending')) and c.case_number=m.case_number group by c.case_number, u.email,c.assigneddate_chart,m.date_entered
Output:
CASE_NUMBER---EMAIL---ASSIGNEDDATE_CHART---LAST_DATE_ENTERED---DAYS_LATE--ADDL_DAYS_LATE
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
I am wanting to achieve this result:
Therefore, based on the data below, are the only records I am wanting to display:
[email protected]
[email protected]
Thank you
DeannaSELECT case_number, email, assigneddate_chart, date_entered, trunc(sysdate)-trunc(assigneddate_chart) days_late, trunc(sysdate)-trunc(date_entered) addl_days_late FROM ( SELECT c.case_number, u.email, c.assigneddate_chart, m.date_entered, dense_rank() over(partition by c.case_number order by m.date_entered DESC) rnk FROM chart c, chart_user_roles u, comments m WHERE c.case_status IN ('Open','Pending') AND c.case_number=m.case_number ) WHERE rnk = 1 /
SY.
Maybe you are looking for
-
People with disabilities Add ons for the last pass and XMarks running Windows 10
Last pass. E Web and XMarks modules disabled on my PC using windows 10. My Mac uses the last pass, XMarks E-Weband and it still works. Why are they add ons disabled on the PC, not Mac. I've used these all day and if Firefox will continue to turn off
-
I have a Macbook Air Mid 2011 with OS X 10.7.5 and due to the lack of space just to order a tardisk of 128 GB, but it seems that I need to upgrade the operating system. This HW supports the new operating system? Which? Anyone using tardisk?
-
Activity &; Heath Apps do not work
I have an iPhone 6. About 2 weeks ago health and business apps stopped working and follow all the data. I have not matched & paired my Apple Watch & even gone as far as clear my iPhone & relocation of a back-up all to nothing does not. I turned on an
-
Question of Synaptics Satelite A300
Hey there, I just noticed that it is not possible to open a new tab (by pressing both mouse buttons at the same time) in Firefox or IE for example, I really got used to do and I tried to do by changing the synaptics setting, but however, when I put t
-
Hello, asking for ideas/help for high vi.
Hello, excuse my rookieness lol. Just, I acquired my CLAD certification and began to get wet feet. With all of your experience, I was wondering what you might think, this is the best way (read simpler) to create a vi that is a simple drop-down menu