Filtering out rows based on field value
Hello,
I have something like this:
create table stuff
avalue varchar2,
anothervalue varchar2,
thirdvalue varchar2,
anumber number
INSERT INTO stuff Values('abc', 'cde', efg', 2);
INSERT INTO stuff Values('abc', 'cde', efgggg', 4);
INSERT INTO stuff Values('abc', 'xxx', efg', 1);
INSERT INTO stuff Values('abc', 'xxx', efgxxx', 2);
INSERT INTO stuff Values('abc', 'yyy', efg', 2);
I would like to recieve the rows with the higest 'anumber'-value, grouped by 'avalue', and 'anothervalue' (but not 'thirdvalue'). So in this example I want row 2, 4 and 5.
Anyone have an idea? I'm thinking a 'order by desc' is not the best way here?
select avalue,
anothervalue,
thirdvalue,
anumber
from (
select s.*,
rank() over(partition by avalue,anothervalue order by anumber desc) rnk
from stuff s
where rnk = 1
AVALUE ANOTHERVAL THIRDVALUE ANUMBER
abc cde efgggg 4
abc xxx efgxxx 2
abc yyy efg 2
SQL> SY.
Similar Messages
-
Count the number of rows based on the values!!!
Hi all,
What I am using:
I am working with a multidimensional database in Visual Studio 2010 using its Data source view and calculation member and dimension usage.
What I want to do:
I have a fact table that has five columns(leg(s),hand(s), Head and body,overall) that shows the category of how severe the injury is. Let say for the records all columns never have an empty value(no injury is stated with 'No injury' ) . These five columns
are connected with a dimension that has all the available values (Category A-E of injury).The overall has the most severe from the other four columns. I want to create a bar chart with five different measure
values, one for each column, and count the values in those columns.
For example : I have a slicer in the excel and a bar chart and the slicer has all the values of the Category of the injury ( Cat a,Cat B, Cat C, ... Cat E, No injury ) and when i select one of them, lets say
Cat C, the bar chart should update and show how many Cat C each measurement column has.
Example FACT table:
ID LEG HAND HEAD BODY OVERALL
1 No A No No A
2 No D C C C
3 E C D A A
4 E E B C B
So if i selected C the bar chart will count (Leg = 0, Hand = 1, Head = 1, body = 2 and Overall = 1).
Any ideas ?
Thanks for the help and the time :)Hi DBtheoN,
According to your description, you want to create a chart on excel worksheet to count the rows based on the value, right? If in this case, I am afraid this issue is related to Office forum, I am not the expert of Office, you can post the issue on the corresponding
forum.
However, this requirement can be done easily on SQL Server Reporting Services. You can using the expression below to count the rows.
=COUNT(IIF(Fields!LEG.Value=Parameters!TYPE.Value,1,NOTHING))
Regards,
Charlie Liao
TechNet Community Support -
Color report rows based on a value in that row
I would like to Color report rows based on a value in that row.
For examplle with the "EMP" table:
I would like job=MANAGER to be red and job=CLERK to be green etc etc
The other example I found only had the option of one color either the highlight or the default color.
I am looking for a way to do multiple colors.Hi,
In the row template, you can use #1#, #2#, etc to indicate where a field in the report needs to be output. This does not have to be plain text - ie, you can use it within style tags if you like.
So, take a query like:
SELECT EMPNO,
ENAME,
DEPTNO,
DECODE(DEPTNO, 10, 'green', 20, 'red', 30, 'cyan', 'white') BG_COLOUR
FROM EMPYou get columns 1=empno, 2=ename, 3=deptno and 4=bg_colour. In the row template, you can then do:
Before Rows setting (sets up the table):
<table>
<tr><td>ID</td><td>Name</td><td>Dept</td></tr>After Rows setting (closes the table):
</table>Row Template 1 (used for ALL rows):
<tr style="background-color:#4#;"><td>#1#</td><td>#2#</td><td>#3#</td></tr>Then, for every row, the colour that has been calculated using the DECODE function will be used in the style tag to colour the background for the entire row.
How you determine the colours is up to you. I've used DECODE here, but you could use a field on the DEPT table to hold this and use this in your SQL statement.
Andy -
Hot spot for field based on field value
Hi,
Im using ALV list to display report. And I have enable hot spot for that field based on field value. For example, If the field has value " 0 " then hotspot should be enabled for that field. If the field has value " 1 " then it should be displayed as normal field without hotspot.
Can anyone tell me how to do this?
Thanks,
AmalHi Amal
Do this
In your final internal table
add a table type
gi_cellstyles TYPE lvc_t_styl
Then (while populating output)
FORM prepare_edit_output.
* say your field is 'field'
DATA : lw_stylerow TYPE lvc_s_styl,
li_styletab TYPE lvc_t_styl.
IF gw_output-field = '0'.
CLEAR lw_stylerow.
lw_stylerow-fieldname = 'FIELD'.
lw_stylerow-style = cl_gui_alv_grid=>mc_style_hotspot.
APPEND lw_stylerow TO li_styletab.
ELSEIF gw_output-field = '1'.
CLEAR lw_stylerow.
lw_stylerow-fieldname = 'FIELD'.
lw_stylerow-style = cl_gui_alv_grid=>mc_style_hotspot_no.
APPEND lw_stylerow TO li_styletab.
ENDIF.
INSERT LINES OF li_styletab INTO TABLE gw_output-gi_cellstyles.
ENDFORM.
In your layout building
gw_layout-stylefname = 'GI_CELLSTYLES'.
Pushpraj -
Hide one row on Advanced List Pane based on field value
Hello everyone,
I have a question for you:
Is it possible to hide one row on an Advanced List Pane based on the value of a field of that row?
Here is the actual case:
I have a custom B.O. called "Product Group". This B.O. has an Internal ID and a Description at Root level.
In this B.O. I have a One-Too-Many node called "Descriptions".
On the T.I. of the Product Group there is a tab called "Other Languages". On this tab a user can provide translations for numerous languages for the Product Group Description.
When you create a new Product Group a translations is automatically added for the Current User Log On Language.
Now I want to hide that row in the Advanced List Pane and only show the translations where the "Target Language" is DIFFERENT from the Current User Log On Language.
So in the screenshot above you see we have 3 translations: "Bébé" (FR), "Baby" (EN) and "Bebé" (ES).
Now I want to hide the "Baby" (EN) translation if the Current User Log On Language is English, hide "Bébé" (FR) translation if the Current User Log On Language is French, etc. ...
The Advanced List Pane is currently bound to Descriptions node.
Thanks & Regards,
GlennHello Glenn,
Please refer the below video.
SAP Cloud Dev: Extensibility and Dynamic UI - Part 1 - YouTube
Here Dynamic UI is achieved for input field. You can create transient radio button for each possible records, check the User Logon Data and uncheck the radio button specific to it.
Regards,
Chandan -
Hiding a subform based on field value.
Dear Friends!
I am trying to hide one subform when I have certain value in text field. I tried following code but it didnt help me at-all. will it be possible for you to show my my mistake.
the business case is I am not supposed to display Form 16 related information in payslip when payroll areas are 13 & 14 for other payroll areas form 16 should display. here subformname is Form16.
code:
data.#pageSet[0].Page1.Form16.Form16::ready:form - (JavaScript, both)
IF(data.page1.payslipheader.GV_ABKRS.rawValue == 13);{
Form16.presence = "hidden";
IF(data.page1.payslipheader.GV_ABKRS.rawValue == 14);{
Form16.presence = "hidden";
above code is not hiding Form16 subform.
thanking you
Regards
NaimHi Soumik,
that is a easy issue. Create a condition, where you ask the value, if it is initial.
In this discussion, exact your question is solved.
Adobe forms: Hide table rows based on data
or here is another way to solve your issue
Hiding a table column for a particular condition
This is the code you need:
if ( this.yourvalue.rawvalue == " " )
this.presence = "hidden";
Please use the search, which is located in the upper right corner of SCN before open a discussion.
Here you can learn more about it:
How to use SCN search
Regards
Florian -
Combine rows based on column value
I'm trying to combine rows based off of a common value.
Table Data:
Result A
Player_ID Player_Name Team_Name Points Sequence
99999 John Smith Bulls 50 1
99999 John Smith Pistons 14 2
What i want in the output
Result B
Player_ID Player_Name Team_Name Points
99999 John Smith Bulls 64 (50 for Bulls)Here's my main query...
select player_id, player_name, team_name, points
from
SELECT player_id, player_name, team_name, sum(points) sum_points
FROM stats_data
WHERE season_id = 2008
AND points > 0
GROUP BY player_id, player_name, team_name
) t
ORDER BY sum_points DESC, last_name;**The current query gives me the output from Result A
1) Not entirely sure how to combine data based of player_id
2) Once i figure out 1, im sure by adding the ('sum_points' for 'team_name') to the output can be done with a case statement, i think?Sorry about that Frank.
Using: Oracle 10.2g
i was incorrect about the output of the query
SELECT player_id, sum(points) sum_points
FROM stats_data
WHERE season_id = 2008
AND points > 0
GROUP BY player_id
)Output
Player_ID Sum_Points
99999 20
55455 6
66489 2 So the subquery is outputing the correct data
The output of the original entire query(that you had posted) is:
Player_ID Player_Name Team_Name Points
99999 John Smith Bulls 16 (8 for Bulls)
55455 Bob Johnson Rockets 6 (3 for Rockets)
66489 Chris Terry Kings 2 (1 Kings)Here's some more raw sample data from the table:
Player_ID Player_Name Team_Name Points Sequence Game_Type_ID Team_ID
99999 John Smith Bulls 12 1 1 5
99999 John Smith Bulls 0 1 -1 5
99999 John Smith Pistons 4 2 1 12
99999 John Smith Pistons 0 2 -1 12
55455 Bob Johnson Rockets 4 1 1 3
55455 Bob Johnson Rockets 0 1 -1 3
66489 Chris Terry Kings 2 1 1 8
66489 Chris Terry Kings 0 1 -1 8So your code frank is very close, the issue is that:
A) All players have a ('pt value' for 'team name') even if they played on the same team, which can prob. be solved with a case statement, which i tried to do in my last post.
WITH grouped_data AS
SELECT player_id, sum(points) sum_points
FROM stats_data
WHERE season_id = 2008
AND points > 0
GROUP BY player_id
SELECT g.player_id
, s.player_name
, s.team_name
(case when sequence = 2 then g.sum_points <==
|| '('
|| TO_CHAR (s.points)
|| ' for '
|| s.team_name
|| ')'
else to_char (g.sum_points)
END) AS points
FROM grouped_data g
JOIN stats_data s ON g.player_id = s.player_id
WHERE s.sequence in (1,2) <==
AND s.season_id = 2008
AND s.points > 0;the output has two issues, for players who played on more than one team, like Josh Smith the output comes out as
99999 John Smith Pistons 20 (2 for Pistons)
99999 John Smith Bulls 20While the players who played on one team came out correctly. So issue with my edit of your code is:
A) josh smith is output 2, needs to be output once
B)josh smith should say (Josh Smith Bulls 20 (4 for Pistons) not "99999 John Smith Pistons 20 (2 for Pistons)"
c) Issues with "99999 John Smith Pistons 20 (2 for Pistons)" is that it listing the wrong team for him: should be Bulls and listing half of his total with the pistons in the prentices should be 4. --The reason that is because s.points needs to be summed as based off of the data there's two entries
Hope this clears it up, thanks!
Edited by: user652714 on Mar 11, 2009 9:28 AM -
How to find out the structure stored field value in a standard program
Hi Gurus,
Please suggest me how to find out the structure field stores the value in which table.
Exanple : i have a strutured field in T.code cj31 is BPDY-WERT1 and it is stotring value 10,000,000.00. know i need to find out in which table this value is storing .
Please suggest me its urgent.
Thanks in Adavance!!!
Points will be rewarded.......
Regards,
Kranthihi,
Go to transaction ST05,Click activate trace with filter,Give the transactio name as cj31,Go to the transaction and navigate to the place where the particular field is present, then again go to st05 ,Deactivate the trace and display the trace.
Now u can see how the data is fetched ,U can even go to display mode of the same transaction cj33
Thanks
San -
How can I select and delete rows based on the value in one column?
I searched through the discussion board, and found a thread on deleting blank rows, but not sure how to modify it to work with my issue.
I have put together a rather complicated spreadsheet for designing control systems, it calculates parts needed based on check boxes selected in a second spreadsheet.
Since not all systems require all parts there are many rows that have a 0 quantity value, I would like to select these rows and delete them once I have gone through the design phase (checking off required features on a separate sheet).
I like the way the other thread I found will gather all the blank rows at the bottom without changing the order of the rows with data in them.
I don't understand exactly how the formula in the other thread works well enough to modify it to look for a certain column.
I hope I made myself clear enough here, to recap, I would like to sort the rows based on a zero value in one (quantity) column, move them (the zero quantity rows) to the bottom of the sheet, and then delete the rows with a zero quantity (I can delete them manually, but would like to automate the sorting part).
Thanks for any help anyone can provide here.
DannyI apologize but, as far as I know, Numbers wasn't designed by Ian Flemming.
There is no "this column will be auto-destructing after two minutes"
You will have to use your fingers to delete it.
I wish to add a last comment :
if your boss has the bad habit to look over your shoulder, it's time to find an other one.
As I am really pig headed, it's what I did. I became my own boss so nobody looked over my shoulder.
Yvan KOENIG (VALLAURIS, France) mercredi 13 juillet 2011 20:30:25
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
Please : Search for questions similar to your own before submitting them to the community
To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer ! -
Brf+ workflow configuration based on field values of UI
Hello Experts,
I would like to know if we can configure the BRF+ workflow steps for material to go to certain users based on certain values from UI fields . For example a particular material type (FERT) should go to specific processor . Can I add material type column in BRF+ for materials and assign specific material type values and assign users to that step. Is this possible?.
Thanks.This is one of the most common questions. It will save you time if you perform some research before asking. Any way, review this document: How to-Master Data Governance for Material: BADI USMD_SSW_RULE_CONTEXT_PREPARE to Enhance User Determination which addresses your exact question.
Also, for any future MDG questions, please take a look first at this document Configuration and Enhancement of SAP Master Data Governance as it contains many of the commonly required enhancements. -
Mapping requirment based on field value
Hi All,
I have a mapping requirement
where in the file i have a 2 AM records as shown
AM U 00000000000010000C
AM X 00000000000120000
Based on AM-03 field i..e,, AM-03 = 'C'
then to the target field i need to pass the value(00000000000120000) of next AM02 record.
so when ever AM03 filed is 'C' then i need to pass the value of next AM record.
can any body suggest me how i it can be acheived.
Thanks
Sai_SHAi am not sure whether i have understood ur req correctly or not..
but u can chk this UDF in ur mapping:
execution type: all values of a context
if(var1[0].equals("C"))
result.addValue(var2[1]);
filed3---removecontext
UDF----target
field2---removecontext -
Required Fields based on field value
I am using Acrobat 9.1 Std. This is what I am trying to accomplish I have four text fields that I want to make required based on the selection of a radio button group.
I have two radio buttons on the form w/ the same name w/ the button value set to Yes for one and No for another. If the radio button w/ value Yes is selected I want to set the four text fields to required. If the radio button value is No the text fields should be optional.
Ive found similar postings for what I am trying to accomplish; however, I havent had any success in getting it to function correctly.Some more information on what I have tried..For simplicity Im just trying to get one text field to work, then I can repeat the java code for the other text fields.
In acrobat Standard 9.1 I go to Forms Add or Edit Fields from there I select the radio button group (contains two radio buttons) on the left column and select properties. Then on the radio button properties dialog box I select the Actions tab. Set the Trigger for Mouse Up and the Action for Run a JavaScript . I click the Add button and enter the following into the JavaScript editor:
if (this.rawValue == "Yes") {
TextField1.validate.nullTest = "error";
xfa.layout.relayout();
else {
TextField1.validate.nullTest = "disabled";
xfa.layout.relayout();
I then close the JavaScript editor, save the form and re-open to test it. I select the radio button w/ value Yes and click the Submit button and the form goes on to submit. At this point I would expect it to error because I didnt fill in any value for TextField1.
I also tried altering the field tag with the below java:
if (this.rawValue == "Yes") {
TextField1.mandatory = "error";
xfa.layout.relayout();
else {
TextField1.mandatory = "disabled";
xfa.layout.relayout();
This also didnt work. Im not sure if I am using the correct tag or not or why I am unable to get the text field to become required for submission.
Any help would be greatly appreciated.
Thanks, -
Restrict OVS Entries Based on Field Value
Hello everyone,
I've had a look at this section of the SCN for help before posting here --- none seemed to quite fit the bill. Apologies if pre-existing help for this already exists.
I'm modifying the 'projects' WorkCentre for a customer: they have a Customer Contact field which I've added to both the project creation and project overview screens, and turned into an OVS which was easy. They now have an additional requirement --- filter that OVS based on the company named as the buyer on the project creation screen. In theory it's pretty simple --- only show those contacts who have the same company as field X --- but I can't figure out how to go about it. Is there a simple bit of Ruby script to filter this? Do I need to create a custom OVS and do some ABSL scripting? Any help would be appreciated.
LewisDid it!
Tried as Fred suggested and tested it on a custom screen, which worked. Process was thus:
I used the Company OVS which was in publicovs/organisationalcentreid because others caused issues, but this might not be the case for others. In the system I was using, the OrganisationalCentreID of the company I was testing against was a different length ('1000' instead of the expected '10000000') than the BusinessPartnerInternalID associated with it. This is why the second element is needed. Using AfterModify coding, I did the following:
This gets the BusinessPartnerInternalID of the company, which is the same as the RelationshipBusinessPartnerInternalID field used in the Contact OVS. Using the parameter binding I just matched up these two and voilà. One can also make the second field invisible so one doesn't clutter up their UIs.
There is I believe a Company OVS which is in the BusinessPartner subsection of the publicovs folder, which may negate having to have the extra field --- however I was experiencing issues using that, so I'm playing it safe for now. If this solution doesn't work on the customer's system in the standard screen I'll just take it up with SAP. Thanks all for your help! -
Populating apex item checkbox in report row based on database value
Hi All
I am looking for help setting an apex item checkbox to 'checked' depending on a record exisiting in a database and I would appreciate a little guidance.
At the moment I have a report which looks a bit like this
SELECT licence_user_identifier,
description,
licence_name,
apex_item.checkbox(22,licence_id)
FROM TABLE(SOL_LICENCE.F_RETRIEVE_ORG_LICENCES ( 121 ));
4 columns and the last column is a checkbox called 'assign' and is used to assign the selected licence to a user(who is already displayed on the page in another table). There is save button which when clicked saves a record to the database if the checkbox is selected.
However when the page is displayed the checkbox should be prepopulated/checked if there is a record in the database saying that the licence is assigned to the current user. I have created a page process to try and collect this information and populate the checkboxes on load - before header. However I am having difficulty referencing the apex_application item the corresponds to each row because when I use the FOR i IN 1 .. apex_application.g_f22.COUNT LOOP it only selects the item if it is checked. Can anyone point me in the right direction?
here is the process I have to populate the checkboxes, it is not getting to my flow.debug as there are no selected checkboxes:-(
DECLARE
v_count NUMBER;
CURSOR getlicences (p_co_id so05.co_id%TYPE)
IS
SELECT licence_id
FROM so05_cust_org_licences
WHERE co_id = p_co_id;
BEGIN
IF :p9_co_id IS NOT NULL
THEN
FOR each_rec IN getlicences (:p9_co_id)
LOOP
--check if a record exists
SELECT COUNT ( * )
INTO v_count
FROM so05_cust_org_licences
WHERE co_id = :p9_co_id AND licence_id = each_rec.licence_id;
--if the record exists populate the checkbox
IF v_count > 0
THEN
FOR i IN 1 .. apex_application.g_f22.COUNT
LOOP
wwv_flow.debug ('bbbbbbbbbbccccccccccandwearein' || v_count);
IF apex_application.g_f22 (i) = each_rec.licence_id
THEN
apex_application.g_f22 (i) := 1;
END IF;
END LOOP;
END IF;
END LOOP;
END IF;
END;
Thanks in advance
LynnHi,
Sorry my mistake. You can use the above link only to solve this problem, for this you have to use a hidden column to which you will assign 'Y' or 'N' as mentioned in that post.
using that hidden column value you can fire your query accordingly.
let's say your hidden column is f01 and checkbox column is f02 and the id column is f03, you can do like this
create a process before your update process like this
BEGIN
-- Reset the hidden ADMIN_USER flag for all visible records to N
-- Note: g_f01 maps to the hidden ADMIN_USER column
FOR ii IN 1 .. APEX_Application.g_f01.COUNT
LOOP
APEX_Application.g_f01(ii) := 'N';
END LOOP;
-- Set the hidden ADMIN_USER flag for those records where the
-- checkbox has been set by the user to Y
-- Note: g_f02 is the checkbox column ADMIN_USER_CHECKBOX
FOR ii IN 1 .. APEX_Application.g_f02.COUNT
LOOP
APEX_Application.g_f01(APEX_Application.g_f02(ii)) := 'Y';
END LOOP;
END;then write a new process positioning after above process
if apex_application.g_f01 = 'Y' then
your update query using id column (f03)
else
your delete query using that id column (f03)
end if;hope this helps you.
Thanks
Tauceef -
Insert rows based on column value
I have customer_ no., Date and no_months as columns. I need to insert in a new table the customer_no as many times as the value of no_months column. Meaning if customer_no is 001 and if months value is 3 then in the new table I want three rows having customer_no as 001 and the date. Any help is highly appreciated.
Something like this?
SQL> with t
2 as
3 (select 23 cust_no,3 mon from dual
4 union all
5 select 10,9 from dual
6 union all
7 select 5,12 from dual
8 union all
9 select 7,1 from dual
10 )
11 select cust_no,mon
12 from
13 (
14 select cust_no,mon,row_number() over(partition by cust_no order by cust_no) rn from t,dba_tables
15 )
16 where rn<=mon
17 /
CUST_NO MON
5 12
5 12
5 12
5 12
5 12
5 12
5 12
5 12
5 12
5 12
5 12
CUST_NO MON
5 12
7 1
10 9
10 9
10 9
10 9
10 9
10 9
10 9
10 9
10 9
CUST_NO MON
23 3
23 3
23 3
25 rows selected.
SQL>
Maybe you are looking for
-
Outline View In Isolation Mode + Scrollable font list on mac like its on PC
I would love to have outline view available when in isolation mode.. Not sure why its not available.. Also would like to have the scrollable font list on the mac version like how it is on PC..
-
New Computer, is there any way to import songs from an ipod to a computer?
My computer doesn't have the songs from my old computer so I was wondering if there was a way to import songs from an iPod to a computer, because if I update my iPod now, all of my songs will be lost.
-
Hi, Has anybody worked on the CUnit and PUnit test suites in ALBPM? As this is a new feature in ALBPM 6.0, i am not able to find appropriate documentation for the same. Any information regarding this would be very helpful. Namitha
-
Hi I have written sql loader script for loading data into two tables. Script is working ..But output is not coming properly. I want to load data into first table which lines are having first char 'R'. In the second table I have to load data which are
-
What's with the Blue&Green Text (sent as text message
Hi well i just want to know why sometimes my text appears in green and sometimes blue this is an example did she/he received the message? http://i.imgur.com/nsn4xSK.png?1 when i first sent the message was blue now i sent another text yesterday and it