How to check multiple values with another column?
Hi all
create table xxc_abc (col1 , dept_id number number);
create the table xxc_bbb (col2 number,sa_dept_id number);
insert into xxc_abc values (1,10)
insert into xxc_abc values (2,11)
insert into xxc_abc values (3,12)
insert into xxc_bbb values (20.10)
insert into xxc_bbb values (20,11)
insert into xxc_bbb values (20,12)
SELCT
xxc_abc a.,
xxc_bbb b
where a.dept_id = b.sa_dept_id
Expected results
a.Col1 b.col2
--------- --------
1 20
2 20
3 20
I need to get several values a.col1 with the same value of the b.col2 column
a.Col1 b.col2
------- ------
1 20
2 20
3 20
Thank you
Post edited by: Rajesh123 added Test cases in the main Thread
Select the number you want to
with
xxc_abc as
(select 1 col1, 10 dept_id in union double all the)
Select 2,11 Union double all the
Select double 3.12
),
xxc_bbb as
(select col2 20, 10 sa_dept_id union double all the)
Select 20,11 Union double all the
Select 20,12 double
)
Select col1, col2, cnt_all, cnt_not_null, cnt_unique
from (select a.col1, b.col2,
Count (*) on cnt_all (b.col2 partition).
Count (a.Col1) on cnt_not_null (b.col2 partition),
Count (distinct a.col1) on cnt_unique (b.col2 score)
xxc_abc a.,
xxc_bbb b
where a.dept_id = b.sa_dept_id
)
where least (cnt_all, cnt_not_null, cnt_unique) > 1
order by col1
COL1 | COL2 | CNT_ALL | CNT_NOT_NULL | CNT_UNIQUE |
---|---|---|---|---|
1 | 20 | 3 | 3 | 3 |
2 | 20 | 3 | 3 | 3 |
3 | 20 | 3 | 3 | 3 |
Concerning
Etbin
Tags: Database
Similar Questions
-
I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?
Add two new columns after than the original with space separated values column.
Select cell B1 and type (or copy and paste it here) the formula:
= IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
shortcut for this is:
B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")
or
the formula of the C1 could also be:
= IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")
Select cells B1 and C1, copy
Select cells B1 at the end of the C column, paste
-
Column sum based on a single value of another column
Hi all
I've searched and searched, but just can't find if this is even possible, let alone how to do it. What I'm trying to do, it's the sum of a column. However, only summarize the results of this column if a specific value of another column is present. So, for example, the following is a sample database entry:
Rate of pay hours
2.3 $14.00
1.2 $14.00
2.4 $12.50
0.75 $12.50
So for that, I want the sum of hours worked column but only the sum of hours worked if the wage rate is $14.00 and $ 12.50. Because these numbers are generated in a database (with the various people who enter multiple rates of pay), I won't be able to set the where statement to have a specific amount (since I don't know the specific amount each registrant), the amount must be a variable in the where the statement. With MySQLI, I know not how to make the sum of hours worked, but I do not know how the sum of hours worked if and only if the line corresponds to the unique value in the rate column.
Then have it automatically loop through and total hours worked for other unique values in the column salary rate. Finally, out all unique values in the column rate in variables so that I can do the following for each game:
$total1 = $total_hours1 * $wage_rate1 $total2 = $total_hours2 * $wage_rate2 $overall_total = $total1 + $total2
where $wage_rate1 = $14.00 and $total_hours1 = 2.3 + 1.2: etc.
Is it still possible? If so, how? If possible, can someone please let me know a good reference so I can learn how to be the best way to implement?
Thank you
So with that, I get the correct $final_total printed, but I still get the error, 'notice: Undefined variable: final_total. Why is it not defined, but prints the total exact? How to remove the error?
You get this notice is because you use the assignment combined, operator that is normally used to add a value to a variable and assign the new value to it.
$final_total += $total;
is a shortcut for this:
$final_total = $final_total + $total;
The undefined $final_total is on the right side of the assignment operator. The first time through the loop, you add $total to a non-existent value. Because of the type of PHP juggling, this becomes:
$final_total = 0 + $total;
The next time the loop runs, $final_total has a value, so that you get the view variable not defined only once.
To avoid advice, initialize $final_total to zero before the start of the loop.
$final_total = 0;
While ($row = {$sql-> fetch_array())}
-
How to capture the value of type column report
It would be a great help that you might suggest the following
(i) Java script that I wrote on the standard status column (in a tabular report) fails.
This happens because of the standard status column, if I use the text field then called Javascript function and showing correct results.
Now, here, I want to know how to capture the value of the column standard report, since javascript fails due to
the column values of standard report unrecognized.
Example:
Columns of the report as a table:
```````````````````
Standard report column: salary
TextField report column: new treatment
Report column standards: difference
I've written the javascript on column New_salary function which returns the value of the salary column to calculate the difference.
For this column of report types, the javascript function does not work, that is to say, it does not show the difference., since it is not read
the value of the column Salary (which is the Standard type of report column)
Once I have change the Salary column to text (display as saved state) javascript field works fine.
All entries on how to capture the standard value of the column, so that I can access the value of the javascript function.
Thanks in advance
VijayHi Vijay - I had problems with the forum as well (and my workspace OTN so)!
You have two questions, I think.
First of all, that the old wage is not an input element, you can not get to it by referring to an ENTRY tag. you will need to change that to something like:
var s1 = d[k-1].firstChild.nodeValue;
This means that there is nothing else in the cell apart from the text - as in < td > < table > 123. If there is something else there that stops you getting the value using the above, you can go through these nested tags referring to objects further firstChild-
var s1 = d[k-1].firstChild.firstChild.nodeValue;
As I don't see your page, you need to check yourself to see firstChild how much you need. This example assumes that you had something like: < td > < b > 123 < /b > < table >
Second, the values of s and s1 are strings. You must convert these numbers to be able to perform calculations. You have two javascript functions to do this: ('string') parseFloat and parseInt ('string'). One contains decimals, the other is not - but know that one is not very accurate (it can change "123.456' in ' 123.455999999995' or something similar - not very good! '").
So, your calculation should be:
var diff = parseInt(s) - parseInt(s1);
Andy
-
Add column if the value in another column
How can I add a column as column name 'YES_OR_NO.
SELECT VALUE_ID IN THE TABLE TABLE_NAME
VALUE_ID
---
1
2
3
4
5
Now, I want to create another column in the sql query called YES_OR_NO and that if there is a value in VALUE_ID then column YES_OR_NO must say 'YES' if there is no value in the column VALUE_ID of this line YES_OR_NO must say 'NO '.
or just a way for her also to work would be to show this new column or not if a value in another column of table_name_2 (this would be ideal)
If new column yes_or_no and fill by a Yes or a no if a value is found in another tableAssuming that you are on a version that supports the CASE expression:
SELECT VALUE_ID , case when VALUE_ID is null then 'NO' else 'YES' end as YES_NO FROM TABLE_NAME
-
How to rename multiple files with the extension in windows xp
How to rename multiple files with extension in windows XP.
1. If you want to simply rename the extension, open a run window (Windows Logo key + R), type cmd and press ENTER. Using the CD (Change Directory) command, navigate to the folder in question. Now, type ren *.mp3, *.mp4, and press enter (note the two spaces in the command). Note, rename mp3 MP4 is just an example of the command.
2. If you want to rename files, download the 32-bit version or 64-bit Bulk Rename, here http://www.bulkrenameutility.co.uk/Main_Intro.php
-
How to get the value of a column in sql query?
Hi, anyone knows how to get the value of a column in sql query?
Here is my code, the value must be 1350079224397 in my PB, but I get 0
QString query ("SELECT version FROM db_version");
QVariant result = sda.execute (query);
QVariantMap versionMap = result.toList () such () .toMap ();
If (! versionMap.IsEmpty ())
{
qDebug()<"Version: "="">"Version:><>
}OK, I have the solution
QString query ("SELECT version as version FROM db_version");
-
Please share me your ideas for this problem
in the responses, I need to add a link to HTML and parallel to concatenate it with another column
example of think this link as https:\\google.com + another column (column for the google link concatenation)
https:\\google.com + column country so that it can turn directly to page-> https:\\google.com\India
so that helps me to access a particular site of my organization and opening of a given page
Hi 3051369,
Glad it worked.
Could you please mark this question as answered?
Thank you
JeromeFr
-
How to fill one shape with another shape, but not of models
Hello
How to fill one shape with another shape, but not of models. Example of this poster
put in a shape of the tree so that it looks like this:
Select your type with a vector path, which is the subject
Object > envelope distort > make with top object.
-
passing multiple values of the column to a variable in unix
sqlplus -s $USER_ID@$SID/$PWD<<EOF>sql_1.txt set feedback off set heading off select 114032 as c_1 from dual ; EOF for i in `cat sql_1.txt` do sh script_1.sh $i
Currently I am passing a column value to the single unix variable.
How can I pass values of 2 columns
sqlplus -s $USER_ID@$SID/$PWD<<EOF>sql_1.txt set feedback off set heading off select 114032 as c_1 ,sysdate c_2 from dual ; EOF sh script_1.sh $col_1_value $col_2_value
I'm on SUNOS
You can concatenate the columns in SQL by a delimiter, and then use the cut (for example) under Unix to analyze the production line in chips for the script.
-
How do rotate on a date and see the sum of the value of another column
Hello
I searched through the forum and cannot find a query similar to my question feels so post this new thread.
First of all, it is probably useful indicating that I am using Oracle 10 g.
I have a table that is used to store the details of the booking (essentially a booking system) and I would use this data to display the details of the customers stay on one line.
The table has the following columns:
Some example records could be:BOOKING_ID CUSTOMER_ID DATE_OF_ARRIVAL NUMBER_OF_NIGHTS NUMBER_OF_PEOPLE
On this basis I would like to display the output so that I can show a sum of the NUMBER_OF_PEOPLE reserved to per customer per day, as such:BOOKING_ID CUSTOMER_ID DATE_OF_ARRIVAL NUMBER_OF_NIGHTS NUMBER_OF_PEOPLE -------------------------------------------------------------------------------------------- 1 201 13-JAN-2010 5 1 2 202 13-JAN-2010 3 2 3 202 13-JAN-2010 4 1 4 203 15-JAN-2010 2 3
I watched analytical functions in the documentation and several books of Oracle that I have, but have so far struggled to find how to make the performance desired. Even using the excellent response to the previous post on the forum, I got I was not able to get a feasible request.CUSTOMER_ID 13-JAN 14-JAN 15-JAN 16-JAN 17-JAN 18-JAN 19-JAN ----------------------------------------------------------------------------------------- 201 1 1 1 1 1 0 0 202 3 3 3 1 0 0 0 203 0 0 3 3 0 0 0
Any help or advice would be much appreciated.
Kind regards
Stu
Published by: macmanxie on January 10, 2011 21:16Hello
macmanxie wrote:
... The suggested approach goes only to return a number if the DATE_OF_ARRIVAL corresponds to the date in the CASE statement, however I have the added complexity of wanting to show a count of all the days that the customer is booked, for, by making use of the NUMBER_OF_NIGHTS. I tried to use some of the examples provided on morganslibrary.org, for example:sum( CASE WHEN TRUNC (arrival_date) between '01/13/2011' and TRUNC (arrival_date+no_of_nights) THEN nvl(no_of_people,0) ELSE 0 END) AS jan_13
but this does not produce the desired result.
You check if arrival_date is between January 13 and arrival_date + no_of_nights (as if the arrival date could all be posterior to the arrival_date + no_of_nights).
Are not really interested in whether or not January 13 ib between arrival_date and arrival_date + no_of_nights?NVL ( SUM ( CASE WHEN TO_DATE ( '01/13/2011' , 'MM/DD/YYYY' ) BETWEEN TRUNC (arrival_date) AND TRUNC (arrival_date) + no_of_nights THEN no_of_people END ) , 0 ) AS jan_13
Always format your code. It is important to format your code if you are the only who who will ever read but it is even more important if you are posting on a forum like this and ask other people to read.
Not to compare the DATEs in the strings; explicitly use a conversion function, like TO_DATE, above, where necessary.
Both
SUM (NVL (x, 0)) and
NVL (SUM (x), 0) get the same results, but the latter is more effective. If you have 1000 lines, the first way is calling NVL 1000 times, but the second way is calling only once.If your previous thread
Re: How to count the occurrence of a date in a range
Gets you the right data, but it has one row for each distinct combination of customer_id and date, then you can switch it to a form that contains a line by the customer and another column for each date.If you need help, post CREATE TABLE and INSERT statements for some examples of data and outcomes from these data. The post you are trying better to a request, including a subquery that gets no cross-the raw table dynamic results.
There will be a fixed number of columns in the output swing? If this is not the case, how do you deal with that? Which of these options in the thread I posted above)
Re: County report and the sum of the number of rows by multiple columns
) is best for your needs? Than others is acceptable? -
How to set the value of a column in a table according to another column?
Hello world!
I use Apex 4.1.
My question is how can I set the value of a column in a table according to another column?
I have a table and when I insert the value in the column content, I want to change this value in the note column with the note, which is generated with pl/sql function (function of string returned if the typed value is in the range).
I tried to use javascript as
for the development of the column note to test if the value typed in the content of the column is not 1, but this code assigns the value to all the lines and I need to set only the specified line.$('input[name=f02]').live('change', function(){ if($(this).val()!='1'){ $('input[name=f03]').val("test")} });
Can someone give me a hint in any way to do this if possible?
Kind regards
drama9346You will need create a process on your page type PLSQL and develop this process "we demand" of the page. In this process, you can run the PLSQL you need. That is to say to retrieve the note value as described in your PC:
and when I insert the value in the column content, I want to change this value in the note column with the note, which is generated with pl/sql function (function of string returned if the typed value is in the range).
In this process, you must provide a return value of the call, and you can do this by using htp.p. Example:
DECLARE --putting x01 in a var to simplify l_test_var VARCHAR2(200) := apex_application.g_x01; l_return VARCHAR2(200); BEGIN -- a simplistic test IF LENGTH(l_test_var) BETWEEN 10 AND 20 THEN l_return := 'String is between 10 and 20'; END IF; --this will write l_return to the buffer, and the ajax callback will receive this htp.p(l_return); END;
And the code that I wrote above, which is javascript, would need to go where your current code is that binds to the onchange event. The result should be that, when a change is made to this element, an ajax request is made on the server. When the call is finished, it will be the value returned in the item you want.
-
Another REGEXP question: how to extract multiple values from a string
Hi, how can I retrieve multiple values to a string with RegExp with Oracle SQL constructs?
Have looked at the various examples, I cannot understand this.
the following Sql code
Returns CN = A_role.select regexp_substr(sessie."rollen", 'CN=A_role') "A_role" from ( select ' CN=A_role,OU=a_org_unit,OU=another_org_unit,DC=bz,DC=ad,DC=min,DC=local CN=Another_role,OU=some_org_unit,DC=bz,DC=ad,DC=min,DC=local CN=Users,OU=Dep,DC=bz,DC=ad,DC=min,DC=local ' "rollen" from dual ) sessie;
I want him back all of the CN = concatenated values with a semicolon and stripped of the CN = bit.
So: A_role; Another_role; Users .
Any help would be much appreciated. Here I use database 11g 11.2.0.2.0.
Does anyone have an idea how to do this in SQL?
best regards MikeHello
If using Oracle 11 gwith tst as (select 'CN=A_role,OU=a_org_unit,OU=another_org_unit,DC=bz,DC=ad,DC=min,DC=local,' ||'CN=Another_role,OU=some_org_unit,DC=bz,DC=ad,DC=min,DC=local,' ||'CN=Users,OU=Dep,DC=bz,DC=ad,DC=min,DC=local' as rollen from dual ) select listagg(sub, ',') within group (order by rn) as res from (select regexp_substr(rollen, '(CN=)([[:alnum:]_]+)',1,rownum,'i',2) sub, rownum rn from tst connect by level <=length(rollen) ) where sub is not null
-
How to create a table with editable column values.
Hello world
I think it's very simple, but I am unable to find how to do this. This is my requirement. I need to create a table with n columns and 1 line initially. the user must be able to enter data into this table and click of a button must insert the data into the database table. Also, there should be a button at the bottom of the table to add 1 line to the table.
I know how to do the insertion of data, but can someone please let me know how to create a table which allows the user to enter data and how to create a line button Add 1?
Thanks in advance!Raghu,
Go through the tutorial of Toolbox Page & Advanced section of the Guide of the OFA table.
Step 1 - you need to create EO & VO from this EO. This EO will be table of database where you want to insert the data.
Step 2 - create an advanced table region. (See this section in table advanced for more details)
Step 3 - attach this VO in the BC4J region advanced Table component.
Kind regards
GYAN -
How to use the value of the column in the old testament even another column in the report
I have a report based on a query like this
SELECT
"AAA."
'BBB '.
FROM TABLE2
and AAA is a NUMBER related to the TABLE1 table. I try in the column attributes writing a correct LOV. In this LOV I have to use a current value of the a.
Fe SELECT CCC | » '|| DDD FROM TABLE1 WHERE EEE = #AAA #.
The question is how to get the value of AAA to this query (#AAA # dosent work)?
the second way to fix this problem I thought changed the first request:
SELECT
"AAA."
"BBB."
APEX_ITEM. SELECT_LIST_FROM_QUERY
(2, NULL,'SELECT CCC |) » ''|| DDD FROM TABLE1 WHERE EEE = 'AAA' ') "FFF".
FROM TABLE2
but problem is the same... You have a solution?
THX in advanced for any helpHello
OK, try this
X_ITEM. SELECT_LIST_FROM_QUERY (1, (SELECT CCC |)) » '|| DDD FROM TABLE1 WHERE EEE = AAA),'SELECT CCC | » ''|| DDD, CCC | » ''|| DDD FROM TABLE1 WHERE EEE =' | AAA, ","NO")"FFF ".
Concerning
Paul
Maybe you are looking for
-
Latest MBPs are not autonomous RAM/SSD upgrade?
Hello I recently heard that these latest Mbit/s do not allow users to upgrade RAM or SSD. What is the latest model of MBP which will allow upgrades? Would that be a model already abandoned? Thank you very much!
-
G5 will not start. LED light on. Fans before working.
Early 2005 G5. running 10.5.8. G5 will not start. LED light (no flashes not but solid). Fans before working. Rear fans blowing not. Cleaned up the dust. A exploded during a down and will not restart. Any thoughts? Is that a bad diet? What I would do.
-
Hi, I am looking to resolve a dilemma with a backup solution. I have an external hard drive connected to an Airport extreme. It is used for my iTunes music library. Is there a way or a backup software that allows me to save this drive to another exte
-
In previous versions of Firefox, in any tab open with multiple windows open, which is a search where you would go to a lot of different windows, there was a drop down to the right of the ' previous/next' button which would you allow to select before
-
Extract the KING including the overlay
People - you are looking for an effective method with Vision screws to extract a region of interest (paragraph of an image) defined for example by drawing a rectangle on the image. The paragraph in question has information about overlay. The final