How to SUM two count(*) values in a single sql tatement?
How can I get a single SQL statement to sum two values from a count(*)
I want something like this:
SELECT COUNT(*) FROM MYTABLE
UNION
SELECT COUNT(*) FROM MYOTHERTABLE;
but instead of getting
111
222
I want to see the sum of the two values.
333can such a thing be done with one statement. I know I can do stuff inside a BEGIN END and have vars but wonder if there is simple single statement solution.
Thanks in advance,
David Miller
SQL> select count(*) from user_indexes;
COUNT(*)
30
SQL> select count(*) from user_tables;
COUNT(*)
43
SQL> select (select count(*) from user_indexes) + (select count(*) from user_tables)
2 from dual;
(SELECTCOUNT(*)FROMUSER_INDEXES)+(SELECTCOUNT(*)FROMUSER_TABLES)
73
Similar Messages
-
Want to fetch two rows values into a single sql result
Let me first explain the situation first
I am having two tables
1. Animal_details(animal_id,and other details)
2. Animal_weight(animal_id,seq_no,weight,date_weighed)
here actually situation is that for each weight I am inserting a new row with seq_no say
1 for first weight
2 for second weight ....
with their weight and date
eg. animal_id = 1, seq_no = 1, weight = 200, date_weighed = 12-may-2000;
animal_id = 1, seq_no = 2, weight = 250, date_weighed = 12-june-2000;
means seq_no = 1 represents 1st weight of animals
seq_no = 2 represents 2nd weight of the animals
like this an animal can have any no. of times weighted.
now what I want is that I want to show a result with
animal_id,weight_1,weight_2 with other animal details in a single row
how can I have both first weight and the second or more weights in same row for any animal?
Please Reply soon, Its urgent.
ThanksYou can't issue an SQL with 100% dynamic column list. What you can do is issues something like:
with t as (
select animal_id,
max(case seq_no = 1 then weight end) first_weight,
max(case seq_no = 2 then weight end) second_weight,
max(case seq_no = 3 then weight end) third_weight
from animal _weight
where seq_no <= 3
group by animal_id
select t1.animal_id,
first_weight,
second_weight,
third_weight,
other_details
from t t1,
animal_details t2
where t2.animal_id = t1.animal_id
/SY. -
How to change the profile value in the pl/sql code without making change in the database
How to change the profile value in the pl/sql code without making change in the database.
I have program ,where if the profiles 'printer and nunber of copies ' are set at the user level, by default when the report completes the O/p will be sent to the printer mentioned in the set-up. but what user wants is
if these Profiles are set for the user running this program automatic printing should not be done. -
How to refer a column value of a single row in conditional column display?
Hello,
does anybody have an idea, how i can refer a column value of a single row in conditional display of a column?
So my idea is, that a report has a column, which value is only displayed, when another column value of this row has a specific value.
I want to solve this problem with condition type: PL/SQL Function Body returning a boolean.
But I do not know how to refer the column value of each single row!
Thank you,
TimHere's a solution that, to me, seems easier to implement but, that's, of course, in the eye of the implementer.
Rather than using APEX to generate a link column for you, actually create the link as part of your SQL.
select '<a href="f?p=102:3:491847682940364::::P3_CONTACT_ID:' || CONTACT_ID || "><img src="/i/themes/theme_1/ed-item.gif" alt="Edit"></a>' CONTACT_LINK, ...
etc.
Test this out. You'll see that it works just like making a column a link using the column attributes.
Next, we'll change the SQL to use a DECODE statement to either display the link or nothing depending on what your criteria is. For example, let's assume you only want a link for active contacts.
select Decode( CONTACT_STATUS, 'A', '<a href="f?p=102:3:491847682940364::::P3_CONTACT_ID:' || CONTACT_ID || "><img src="/i/themes/theme_1/ed-item.gif" alt="Edit"></a>', NULL ) CONTACT_LINK, ...
etc.
This will not display the link in any rows in which the CONTACT_STATUS is not active, i.e. "A"
-Joe -
How to update two different tables by ony one sql query???
Hi All,
i need to update two different talbes in a single sql query..
i m using the following query
UPDATE FT_User_Alert SET Subscription = 'W' where product_key=1 and measure_key = 12
AND
UPDATE LU_Monthly_Alert_Budget_Sheet SET Min_Red_Range ='16.0' AND Max_Green_Range ='24.0'AND Max_Red_Range ='27.0'AND Min_Green_Range ='16.0' where product_key='1' and measure_key = 12
i m getting the following error:
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43093] An error occurred while processing the EXECUTE PHYSICAL statement. [nQSError: 17001] Oracle Error code: 936, message: ORA-00936: missing expression at OCI call OCIStmtExecute: UPDATE FT_User_Alert SET Subscription = 'W' where product_key=1 and measure_key = 12 AND UPDATE LU_Monthly_Alert_Budget_Sheet SET Min_Red_Range ='16.0' AND Max_Green_Range ='24.0'AND Max_Red_Range ='27.0'AND Min_Green_Range ='16.0' where product_key='1' and measure_key = 12 . [nQSError: 17011] SQL statement execution failed. (HY000)
SQL Issued: EXECUTE PHYSICAL CONNECTION POOL writeback UPDATE FT_User_Alert SET Subscription = 'W' where product_key=1 and measure_key = 12 AND UPDATE LU_Monthly_Alert_Budget_Sheet SET Min_Red_Range ='16.0' AND Max_Green_Range ='24.0'AND Max_Red_Range ='27.0'AND Min_Green_Range ='16.0' where product_key='1' and measure_key = 12
but when i m ushin the same query in Microsoft SQL Server it executes properly:
please help me out...There's no valid syntax for this, but there are some tricks you could do to achieve it.
i) You could place an update trigger on TABLE1 to update TABLE2 automatically.
ii) You could define a view across both tables and add an INSTEAD OF UPDATE trigger to it to maintain them.
If I had to do this I'd choose option2, but frankly I'd just be running two updates if it really was me. -
Update two different tables by a single sql query:
Hi All,
i need to update two different talbes in a single sql query..
i m using the following query
UPDATE FT_User_Alert SET Subscription = 'W' where product_key=1 and measure_key = 12
AND
UPDATE LU_Monthly_Alert_Budget_Sheet SET Min_Red_Range ='16.0' AND Max_Green_Range ='24.0'AND Max_Red_Range ='27.0'AND Min_Green_Range ='16.0' where product_key='1' and measure_key = 12
i m getting the following error:
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43093] An error occurred while processing the EXECUTE PHYSICAL statement. [nQSError: 17001] Oracle Error code: 936, message: ORA-00936: missing expression at OCI call OCIStmtExecute: UPDATE FT_User_Alert SET Subscription = 'W' where product_key=1 and measure_key = 12 AND UPDATE LU_Monthly_Alert_Budget_Sheet SET Min_Red_Range ='16.0' AND Max_Green_Range ='24.0'AND Max_Red_Range ='27.0'AND Min_Green_Range ='16.0' where product_key='1' and measure_key = 12 . [nQSError: 17011] SQL statement execution failed. (HY000)
SQL Issued: EXECUTE PHYSICAL CONNECTION POOL writeback UPDATE FT_User_Alert SET Subscription = 'W' where product_key=1 and measure_key = 12 AND UPDATE LU_Monthly_Alert_Budget_Sheet SET Min_Red_Range ='16.0' AND Max_Green_Range ='24.0'AND Max_Red_Range ='27.0'AND Min_Green_Range ='16.0' where product_key='1' and measure_key = 12
but when i m ushin the same query in Microsoft SQL Server it executes properly:
please help me out...Duplicate thread. I've already answered on your other thread...
update two different tables by a single sql query: -
How to sum a column value using CAML Query?
Hi All,
I would like to sum the column value using CAML qeury. Actually in my list, I have two column "Projects Name" and "Number of Issues". Now need to get sum of "Number of Issues" column. How to achieve in CAML Query.
Thanks in advance!Hi Sam,
it looks like you can use your current view based agregation, otherwise it is not possible(
http://msdn.microsoft.com/en-us/library/ms467521.aspx) and you need to work on custom bit on this requirement.
use the below link and create a view element as described and see if that works for you
Aggregations Element
http://msdn.microsoft.com/en-us/library/ms468626%28v=office.12%29.aspx
Another reference
Query Element
http://msdn.microsoft.com/en-us/library/ms471093.aspx
Hope this helps!
Ram - SharePoint Architect
Blog - SharePointDeveloper.in
Please vote or mark your question answered, if my reply helps you -
How to acquire two signal values from the same GPIB
I have a power meter which provides two values, the power and wavelength simultaneously. So when I'am giving in the GPIB write command probe a joint command is not provided by ILX light wave. So how can i get the values simultaneously.
Please helpHi perumpadapu,
you should read the manual of your device/software. There you should find the answer.
Or ask the customer support for that device.
As long as you don't even provide a name of your device we cannot provide much more help!
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
How to campare two date values ?
Hi,
I want to compare two string values which has date values.
Here i post my sample code :
import java.util.*;
public class Now {
public static void main(String arg[]) {
try{
String pre_date="";
Calendar cal = Calendar.getInstance(TimeZone.getDefault());
String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
java.text.SimpleDateFormat sdf =
new java.text.SimpleDateFormat(DATE_FORMAT);
sdf.setTimeZone(TimeZone.getDefault());
String sdd= sdf.format(cal.getTime());
String sysdat = sdd.substring(0,10);
String pdate = "2007-02-08 18:11:44.0";
pre_date = pdate.substring(0,10);
System.out.println("sysdate is "+sysdat);
System.out.println("previous date is "+pre_date);
if ((pre_date==sysdat)) {
System.out.println("hai ");
else{
System.out.println("welcome ");
catch(Exception e){
System.out.println("Error in file "+e.getMessage());
e.printStackTrace();
}Here the else part has been executed.
But both values are same
Please anybody helpe me how to compare these values in if condition
Thanks
MerlinRosinaif ((pre_date==sysdat)) is wrong
U need to use pre_date.equals(sysdat) -
How to get record count value in variable
Hi,
i wanted to capture record count value in the variable?
Please let me know how to do this?
Thanks,
jagTo determine count of records, use: count(field_name) -- replace field_name with your appropriate field.
You don't have to save the record count value in a variable. You can directly use the condition <?if: count(field_name) > 0?> display table <?end if?>
If you want to store it in a variable: use <?variable:record_cnt;count(field_name)?>
Take a look at this post that uses a record count: https://blogs.oracle.com/xmlpublisher/entry/no_data_found
Thanks,
Bipuser -
How to merge two A5 pages into a single A4 page.
I have three PDF documents that I want to print duplexed onto a single A4 sheet. The first two pages (front and back) are A5 which is causing a problem when printing as it will not allow me to print in booklet format without cropping the back page.
Is there any way to combine the two A5 pages into a single A4 page within Acrobat??
I am currently running Acrobat 6.0 Standard on Windows XP SP2When you have been around since AA5 and earlier, the printer used to be the trick to doing things. Since AA5 a lot of the features have been built into Acrobat and it might be possible to create the page in another way. However, the print approach should still work.
-
How do i implement this logic in a Single SQL?
Hi Friends!
I’m having some problem. Hope you can share your thoughts with me.
Let’s come to the problem
I’m having following recordset
S_id t_nbr d_id a_dtm b_dtm c_dtm create_tmstmp ind_f
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:48:00 22-Nov-2007 13:43:00 23-Nov-2007 01.01.14.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:58:00 22-Nov-2007 13:43:00 23-Nov-2007 01.03.00.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 14:30:00 22-Nov-2007 14:44:00 23-Nov-2007 01.04.05.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 14:31:00 22-Nov-2007 14:45:00 23-Nov-2007 01.04.07.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 14:31:00 22-Nov-2007 14:45:00 23-Nov-2007 01.04.22.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:29:00 22-Nov-2007 13:43:00 23-Nov-2007 01.05.46.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:29:00 22-Nov-2007 13:43:00 23-Nov-2007 01.06.01.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:29:00 22-Nov-2007 13:43:00 23-Nov-2007 01.07.13.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:40:00 22-Nov-2007 13:43:00 23-Nov-2007 01.08.26.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:51:00 22-Nov-2007 13:43:00 23-Nov-2007 01.09.27.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:01:00 22-Nov-2007 14:43:00 23-Nov-2007 01.10.19.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:29:00 22-Nov-2007 15:43:00 23-Nov-2007 01.11.46.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:29:00 22-Nov-2007 15:43:00 23-Nov-2007 01.12.01.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:29:00 22-Nov-2007 15:43:00 23-Nov-2007 01.20.13.000000000 AM LNow,
We have to consider a record as duplicate if the combination of a_dtm||b_dtm||c_dtm are same.
First, we have to select all the unique record. That will be part of our output -
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:48:00 22-Nov-2007 13:43:00 23-Nov-2007 01.01.14.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:58:00 22-Nov-2007 13:43:00 23-Nov-2007 01.03.00.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 14:30:00 22-Nov-2007 14:44:00 23-Nov-2007 01.04.05.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:40:00 22-Nov-2007 13:43:00 23-Nov-2007 01.08.26.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:51:00 22-Nov-2007 13:43:00 23-Nov-2007 01.09.27.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:01:00 22-Nov-2007 14:43:00 23-Nov-2007 01.10.19.000000000 AM LSecond, we have to deals with the duplicate record.
That means the duplicate record set will be as follows -
set 1:
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 14:31:00 22-Nov-2007 14:45:00 23-Nov-2007 01.04.07.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 14:31:00 22-Nov-2007 14:45:00 23-Nov-2007 01.04.22.000000000 AM U
set 2:
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:29:00 22-Nov-2007 13:43:00 23-Nov-2007 01.05.46.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:29:00 22-Nov-2007 13:43:00 23-Nov-2007 01.06.01.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:29:00 22-Nov-2007 13:43:00 23-Nov-2007 01.07.13.000000000 AM Lset 3:
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:29:00 22-Nov-2007 15:43:00 23-Nov-2007 01.11.46.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:29:00 22-Nov-2007 15:43:00 23-Nov-2007 01.12.01.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:29:00 22-Nov-2007 15:43:00 23-Nov-2007 01.20.13.000000000 AM LSelection of 1 record from each duplicate set:
In case of set 1:
Since there is no 'L' in ind_f column, we will pick the first record from it. So the selected record will be -
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 14:31:00 22-Nov-2007 14:45:00 23-Nov-2007 01.04.07.000000000 AM UIn case of set 2:
Since there is 'L' in ind_f column for the first entry from that duplicate set, we will select the first record as -
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:29:00 22-Nov-2007 13:43:00 23-Nov-2007 01.05.46.000000000 AM LIn case of set 3:
Since there is 'L' in ind_f column, we will start searching from the first record of that duplicate set. We got 'L' in the second record from that set.
Hence we will select the following record -
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:29:00 22-Nov-2007 15:43:00 23-Nov-2007 01.12.01.000000000 AM LSo, our final output will be the combination of distinct record and one record that is selected from our duplicate set. Hence the final output will be -
S_id t_nbr d_id a_dtm b_dtm c_dtm create_tmstmp ind_f
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:48:00 22-Nov-2007 13:43:00 23-Nov-2007 01.01.14.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:58:00 22-Nov-2007 13:43:00 23-Nov-2007 01.03.00.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 14:30:00 22-Nov-2007 14:44:00 23-Nov-2007 01.04.05.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 14:31:00 22-Nov-2007 14:45:00 23-Nov-2007 01.04.07.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:29:00 22-Nov-2007 13:43:00 23-Nov-2007 01.05.46.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:40:00 22-Nov-2007 13:43:00 23-Nov-2007 01.08.26.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 13:51:00 22-Nov-2007 13:43:00 23-Nov-2007 01.09.27.000000000 AM U
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:01:00 22-Nov-2007 14:43:00 23-Nov-2007 01.10.19.000000000 AM L
306 1107 YYZ 22-Nov-2007 12:32:00 22-Nov-2007 15:29:00 22-Nov-2007 15:43:00 23-Nov-2007 01.12.01.000000000 AM LI've already identify the duplicate records in a single SQL query. But, unable to implement this selection approach of single record from the duplicate set.
How do i achive this in a single SQL?
By the way,
I'm using Oracle 9i.
Thanks for your efforts in advance.
Regards.
Satyaki De.
Oops! You are right. I've made the change.
N.B.: The duplicate sets will form based on the create_tmstmp fieldHi, Satyaki.
Your query should be very simple:
SQL> with t as
2 (select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 13:48:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.01.14.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'L' ind_f from dual union all
3 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 13:58:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.03.00.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'L' ind_f from dual union all
4 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 14:30:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 14:44:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.04.05.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'U' ind_f from dual union all
5 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 14:31:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 14:45:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.04.07.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'U' ind_f from dual union all
6 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 14:31:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 14:45:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.04.22.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'U' ind_f from dual union all
7 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 13:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.05.46.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'L' ind_f from dual union all
8 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 13:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.06.01.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'U' ind_f from dual union all
9 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 13:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.07.13.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'L' ind_f from dual union all
10 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 13:40:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.08.26.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'L' ind_f from dual union all
11 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 13:51:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 13:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.09.27.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'U' ind_f from dual union all
12 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 15:01:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 14:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.10.19.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'L' ind_f from dual union all
13 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 15:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 15:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.11.46.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'U' ind_f from dual union all
14 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 15:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 15:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.12.01.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'L' ind_f from dual union all
15 select 306 S_id, 1107 t_nbr, 'YYZ' d_id, to_date('22-Nov-2007 12:32:00','dd-mon-yyyy hh24:mi:ss') a_dtm, to_date('22-Nov-2007 15:29:00','dd-mon-yyyy hh24:mi:ss') b_dtm, to_date('22-Nov-2007 15:43:00','dd-mon-yyyy hh24:mi:ss') c_dtm, to_timestamp('23-Nov-2007 01.20.13.000000000 AM','dd-mon-yyyy hh:mi:ss.ff AM') create_tmstmp, 'L' ind_f from dual)
16 --
17 select *
18 from (select t.*,
19 row_number() over(partition by s_id, t_nbr, d_id, a_dtm, b_dtm, c_dtm order by nullif(ind_f, 'U') nulls last, create_tmstmp) rn
20 from t)
21 where rn = 1
22 /
S_ID T_NBR D_ID A_DTM B_DTM C_DTM CREATE_TMSTMP IND_F RN
306 1107 YYZ 22.11.2007 22.11.2007 22.11.2007 23-NOV-07 01.05.46.000000000 AM L 1
306 1107 YYZ 22.11.2007 22.11.2007 22.11.2007 23-NOV-07 01.08.26.000000000 AM L 1
306 1107 YYZ 22.11.2007 22.11.2007 22.11.2007 23-NOV-07 01.01.14.000000000 AM L 1
306 1107 YYZ 22.11.2007 22.11.2007 22.11.2007 23-NOV-07 01.09.27.000000000 AM U 1
306 1107 YYZ 22.11.2007 22.11.2007 22.11.2007 23-NOV-07 01.03.00.000000000 AM L 1
306 1107 YYZ 22.11.2007 22.11.2007 22.11.2007 23-NOV-07 01.04.05.000000000 AM U 1
306 1107 YYZ 22.11.2007 22.11.2007 22.11.2007 23-NOV-07 01.04.07.000000000 AM U 1
306 1107 YYZ 22.11.2007 22.11.2007 22.11.2007 23-NOV-07 01.10.19.000000000 AM L 1
306 1107 YYZ 22.11.2007 22.11.2007 22.11.2007 23-NOV-07 01.12.01.000000000 AM L 1
9 rows selected
SQL> \PS BTW you're not a newbie in the forum, please, post WITH clause or CREATE/INSERT statement for your data next time. -
How to sum two values given in text boxes?
Hi People,
Am beginner in forms.using oracle 9i with forms 6i.I want to add two values given in two text boxes and result should be displayed in third text box.
how to write the coding in when button pressed trigger of a push button?.pls suggest me.
Regards
VIDSI dont what is problem
Better you recreate the form again
Block3
1. button
2. item1
3. item2
4. item 3.
all item should be in one canvas
on when button trigger
write and code again test it.
give item 1 no
give item 2 no
press the button now
output should at 3rd item.
check and revert back.
kanish -
How to merge two parameter value in WebI
Hi Experts,
I am using Business Object Edge 3.1 sever & MySQL data base.
Question 1:
I have six date field in my universe and one catergory field.
All dates are used for different purpose.
Ex. I have current account opening & Closing date, Money Market Account Opening & Closing Date and say loan account opening & closing date.
I want to count my no. of Opening account & Closing account according to Category.
So in prompt suppose i am giving date like 5/25/2010 to 5/26/2010, so my report should fetch all the account lying in this range.
In short i want only one prompt and i want restrict my all date field with this prompt value.
Question 2:
Can I add my MySQL query in WebI or Universe like "Add Command" in Crystal Report?
Your answer will be appreciated.
Thanks in advance,
RishitIf you give the same "prompt" text for all your prompts/parameters then it will prompt only once. So that's how you can merge the parameters.
The add command is not available. But following workaround may work for you:
Create a query from one of the universe with let's say 3 objects. Now click on the SQL button to view the sql statement. and choose the option for custom sql there. Paste your new SQL ther and save. Just ensure that the number of columns in the SELECT statment mathches with the number of of objects. (3 in this example) and ensure that the data type of the columns and slected objects are matching. I have seen this working, but not gone into very detail.
Anil -
How to sum the count results?
Hi,
I have this query:
SELECT SUM (cnt) FROM
select max(timestamp), min(timestamp), count(1) as cnt from table1
union
select max(timestamp2), min(timestamp2), count(1) from table2
It display sum of all count results. But how to display each result from query and sum result at the end?
Best.OK, thanks, that helps a lot. Though if you could put {noformat}{noformat} before and after your code snippets that would help further.
So you basically want a total at the end:WITH test_data AS (
SELECT 1 col1, TO_DATE('16-AUG-08', 'DD-MON-YY') max_ts, TO_DATE('16-AUG-08', 'DD-MON-YY') min_ts, 1000 cnt FROM DUAL UNION ALL
SELECT 1, TO_DATE('31-OCT-08', 'DD-MON-YY'), TO_DATE('31-OCT-08', 'DD-MON-YY'), 1000 FROM DUAL UNION ALL
SELECT 1, TO_DATE('10-FEB-09', 'DD-MON-YY'), TO_DATE('01-JAN-01', 'DD-MON-YY'),422 FROM DUAL UNION ALL
SELECT 1, TO_DATE('20-FEB-09', 'DD-MON-YY'), TO_DATE('20-FEB-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
SELECT 1, TO_DATE('20-FEB-09', 'DD-MON-YY'), TO_DATE('20-FEB-09', 'DD-MON-YY'),14825 FROM DUAL UNION ALL
SELECT 1, TO_DATE('27-FEB-09', 'DD-MON-YY'), TO_DATE('27-FEB-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
SELECT 1, TO_DATE('28-FEB-09', 'DD-MON-YY'), TO_DATE('26-FEB-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
SELECT 1, TO_DATE('01-MAR-09', 'DD-MON-YY'), TO_DATE('01-MAR-09', 'DD-MON-YY'),1000 FROM DUAL UNION ALL
SELECT 1, TO_DATE('05-MAR-09', 'DD-MON-YY'), TO_DATE('16-AUG-08', 'DD-MON-YY'), 5150 FROM DUAL UNION ALL
SELECT 1, TO_DATE('27-APR-09', 'DD-MON-YY'), TO_DATE('30-OCT-08', 'DD-MON-YY'),8733 FROM DUAL UNION ALL
SELECT 1, TO_DATE('27-APR-09', 'DD-MON-YY'), TO_DATE('20-FEB-09', 'DD-MON-YY'),10000 FROM DUAL)
-- end test data
SELECT col1, max_ts, min_ts, sum(cnt) total_cnt
FROM test_data
GROUP BY ROLLUP((col1, max_ts, min_ts));
1 16-AUG-08 16-AUG-08 1000
1 31-OCT-08 31-OCT-08 1000
1 10-FEB-09 01-JAN-01 422
1 20-FEB-09 20-FEB-09 15825
1 27-FEB-09 27-FEB-09 1000
1 28-FEB-09 26-FEB-09 1000
1 01-MAR-09 01-MAR-09 1000
1 05-MAR-09 16-AUG-08 5150
1 27-APR-09 30-OCT-08 8733
1 27-APR-09 20-FEB-09 10000
45130
11 rows selected.
Maybe you are looking for
-
Plasma TV 1080p as Monitor?
I am looking for a Plasma TV as a 2nd monitor for my Macbook Pro i7 16GB with Thunderbolt I was looking for a monitor maybe an older ACD 30" but I know of someone who uses and recommends a Panasonic Plasma 1080i or 1080p (?) TV as a monitor? Does any
-
How rewrite cd's to Lossless without losing information writen in library
Dear all I've about 700 cd's imported to iTunes with high compression. Now I've bought a new computer with a bigger capacity, and I want to rewrite all cd's to LossLess. My problem is how to do it without having to rewrite again all the information a
-
Username and password do not match
I can no longer authenticate. I get "Username and password do not match". Is there a file I can edit to reset the username and password? Thanks in advance, Mike Britton
-
I have adobe Reader 8 but when I try to open a PDF, they always open up in my Adobe Photoshop Elements 2 program. Anything I can do to make them open in Reader? Thanks
-
Iphoto will not update/download since ios update
I recently updated to ios 10.9. When I tried to update iphoto to 9.5 I get the message,"The product distribution file could not be verified. It may be damaged or was not signed." How can I fix this issue?