Write the sql query to find largest value in row wise without using great
write the sql query to find largest value in row wise without using
greatest fuction?
Another not so good way, considering you want greatest of 4 fields from a single record:
SQL> ed
Wrote file afiedt.buf
1 with t as (Select 100 col1,200 col2,300 col3,400 col4 from dual
2 union select 500,600,700,800 from dual
3 union select 900,1000,1100,1200 from dual
4 union select 1300,1400,1500,1600 from dual
5 union select 1700,1800,1900,2000 from dual
6 union select 2100,2200,2300,2400 from dual
7 union select 2800,2700,2600,2500 from dual
8 union select 2900,3000,3100,3200 from dual)
9 SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) Max_value
10 FROM
11 (SELECT (CASE WHEN col1_col2 > col2_col3 THEN col1_col2 ELSE col2_col3 END) col1,
12 (CASE WHEN col2_col3 > col3_col4 THEN col2_col3 ELSE col3_col4 END) col2,
13 (CASE WHEN col3_col4 > col4_col1 THEN col3_col4 ELSE col4_col1 END) col3
14 FROM
15 (SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) col1_col2,
16 (CASE WHEN col2 > col3 THEN col2 ELSE col3 END) col2_col3,
17 (CASE WHEN col3 > col4 THEN col3 ELSE col4 END) col3_col4,
18 (CASE WHEN col4 > col1 THEN col4 ELSE col1 END) col4_col1
19* FROM t))
SQL> /
MAX_VALUE
400
800
1200
1600
2000
2400
2800
3200
8 rows selected.
SQL> Edited by: AP on Sep 21, 2010 6:29 AM
Similar Messages
-
Can anybody provide the SQL query to find the files uploaded in a particular folder?
Hi All,
Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
Any help is greatly appreciated.
With best regards,
NevinNevin,
Be great if we could know the version of Portal. For Rel. 1, here's the query
select id,masterthingid from wwv_things
where siteid = &site
and cornerid = &corner
&site - Content Area id
&corner - Folder id
if you don't know the folder id, use
select id from wwv_corners where siteid = &site
and name = &folder
Hope this helps. I have run into this situation before. Usually, the culprits were
one of the following:
1. Junk Characters in description of item (caused due to Copy-Paste)
2. Special Characters in the File name
Hi All,
Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
Any help is greatly appreciated.
With best regards,
Nevin -
Finding the largest values of an array without using if condition
Hi,
I am trying to find the largest values of an array without using any if condition. Can any one tell me the solution for that..
ThanksI am trying to find the largest values of an arrayThe 'S' to values suggests that you want not only the largest one, but multiple ones among the largest ones. The best way, I think, is to sort the array, so that its largest values are grouped topgether. If the type is already Comparable, the following single line does the job:
Collections.sort(myArray);After this, the last values of the array are the largest ones.
Jerome. -
SQL Query to find cumulative values for a Financial Year
Dear users,
My requirement is to create a SQL query for a table/view where I have day-wise data. I want to find out cumulative values for financial year by giving any date. It should add the values from start of financial year till that date in the financial year.
I think creating a view of such type will post heavy burden on resources since accuimulation will be done for each day upto that day.
ThanksDear users,
My requirement is to create a SQL query for a
table/view where I have day-wise data. I want to
find out cumulative values for financial year by
giving any date. It should add the values from start
of financial year till that date in the financial
year.
I think creating a view of such type will post heavy
burden on resources since accuimulation will be done
for each day upto that day.
ThanksKumar's solution will serve yours purpose but m not agreed
I think creating a view of such type will post heavy
burden on resources since accuimulation will be done
for each day upto that day. Khurram -
How to check the sql:query is return null value
I have use :
<sql:query var="sql1" dataSource="${db}">
select col_name from table_name
where a=<c:out value="${row.test1}"/>
and b='<c:out value="${row.test2}"/>'
</sql:query>
So, how can I check this statement return null value which is no record within this table?The Result should never be null but can be empty. You can check if the Result is empty using an if tag and checking the rowCount property:
<sql:query var="books"
sql="select * from PUBLIC.books where id = ?" >
<sql:param value="${bookId}" />
</sql:query>
<c:if test="${books.rowCount > 0}">
</c:if>http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL7.html#wp84217
Look for query Tag Result Interface -
How to write the SQL query for generating triangular numbers
Hi,
I have a table ..which stores the sequence number like this
Seq :
1000
1200
1300
1500
1800
1900
Now i want to get a result like this
1000 1000
1200 2200
1300 3500
1500 5000
1800 6800
1900 8700
how can it be achieved. I tried using Lead and lag. but only I can add the n+1 or n-1 results. Please help.I've never heard it called 'triangular numbers' before but I think you're looking for a 'running total':
SQL> WITH data AS
2 (
3 SELECT 1000 AS num FROM dual UNION ALL
4 SELECT 1200 AS num FROM dual UNION ALL
5 SELECT 1300 AS num FROM dual UNION ALL
6 SELECT 1500 AS num FROM dual UNION ALL
7 SELECT 1800 AS num FROM dual UNION ALL
8 SELECT 1900 AS num FROM dual
9 )
10 /* END SAMPLE DATA */
11 SELECT num, SUM(num) OVER (ORDER BY num) AS running_total
12 FROM data
13 ORDER BY 1
14 ;
NUM RUNNING_TOTAL
1000 1000
1200 2200
1300 3500
1500 5000
1800 6800
1900 8700
6 rows selected. -
Find out the sql query for special characters.
Hi,
I have the emp table with column name first_name.In that table i have lot records with first_name inlcudes the below mentioned special characters.
¡ , ¿, ,Ä,Å,ä,ª,À,Á,Ã,à,á,ã,å,Æ,æ,Ç,ç,È,É,Ê,Ë,è,é,ê,ë,Ì,Í,Î, Ï,ì,í,î,ï, Ñ,ñ, ô, º, Ò, Ó, Ô, Õ, Ö, Ø, ò, ó, õ, ö, ø, ß, Û, Ù, Ú, Ü,ù, ú, û, ü, ÿ,
I am looking for the records with includes the above mentioned special characters in the first_name column.
Can u please give the sql query to find out the records.
Thanks&Regards
N.SivaramanI am looking for the records with includes the above mentioned special characters in the first_name column.One way would be:
select emp.*
from emp,
table (
sys.odcivarchar2list ('¡',
'Ä',
'Å',
'ä',
'ª',
'À',
'Á',
'Ã',
'à',
'á',
'ã',
'å',
'Æ',
'æ',
'Ç',
'ç',
'È',
'É',
'Ê',
'Ë',
'è',
'é',
'ê',
'ë',
'Ì',
'Í',
'Î',
'Ï',
'ì',
'í',
'î',
'ï',
'Ñ',
'ñ',
'ô',
'º',
'Ò',
'Ó',
'Ô',
'Õ',
'Ö',
'Ø',
'ò',
'ó',
'õ',
'ö',
'ø',
'ß',
'Û',
'Ù',
'Ú',
'Ü',
'ù',
'ú',
'û',
'ü',
'ÿ'
where instr (ename, column_value) > 0 -
Sql query to find the balances for a customer account wise.
Hi,
Could someone help me with the sql query to find the balances for each customer account wise. This is need to generate the report.
presently we are using this query, but the output doesnot return the expected result.
SELECT sum(nvl(ps.acctd_amount_due_remaining,0)) "Balance"
FROM ra_cust_trx_line_gl_dist_all gld,
gl_code_combinations c,
ar_payment_schedules_all ps,
RA_CUSTOMER_TRX_ALL rat,
ra_customers rc
WHERE c.CHART_OF_ACCOUNTS_ID = 101
and gld.code_combination_id = c.code_combination_id
and rat.CUSTOMER_TRX_ID=gld.CUSTOMER_TRX_ID
and rat.CUSTOMER_TRX_ID=ps.CUSTOMER_TRX_ID
and ps.customer_id=rc.customer_id
and ps.status='OP'
and ps.gl_date <= :PDATE
and ps.org_id=:PORGID
and ps.class in ('GUAR','INV','DM','DEP')
and c.SEGMENT4=:Account_id
and ps.customer_id=:Customer_id
Thanks in advance.
Kalyan.Can someone help us with this.
-
Need sql query to find ten records in sequential manner
Plz help me
I need to have ten records on my page. at the bottom of the page, i want to dispaly the number of pages that have records , just as a google page shows at the bottom. if the moves user moves to the next page , the next ten records must be displayed. suppose the user selects and clicks 5th page then the records on that page are displayed.How can i write the sql query corresponding to this specificationi don't want all records to be fetched at the same time and put on the server, rather whenever the page is opened , the corresponding records are fetched and displayedHi
Maybe you should use a CachedRowSet.
Look this:
http://developer.java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/
This page has a example that will help you. -
How to write the sql statement of my finder function in cmp?
hi,
I create a cmp ejb from table INFOCOLUMN,and I create a my finder function ,which sql statement is :
select * from INFOCOLUMN WHERE employee_id=id
employee_id is a column of the table,and id is the finder function parameter.
The error is : invalid column name
So,how to write the sql statement.
Thanks .Mole-
Bind variables are of the form $1, $2, etc., so your query stmt should look like:
select * from INFOCOLUMN WHERE employee_id=$1
-Jon -
How to write a sql query to retrieve data entered in the past 2 weeks
Hi,
I have file names and last accessed date(java.sql.Date format) stored in my database table, I would like to know how I can write a query to get the name of files accessed in the past 2 weeks,I use open sql server at the back end.
Thanks in advance.This has essentially nothing to do with JDBC. JDBC is just an API to execute the SQL language using Java and thus interact with the databases.
Your problem is related to the SQL language, you don't know how to write the SQL language. I suggest you to go through a SQL tutorial (there is one at w3schools.com) and to read the SQL documentation which come along with the database in question. A decent database manfacturer has a website and probably also a discussion forum / mailinglist as well.
I'll give you a hint: you can just use equality operators in SQL like everywhere. For example: "WHERE date < somedate". -
How to find out which Tables have been accessed without looking at the SQL query ?
Hi,
I would like to know is there a way to find out what queries have been executed and on which tables without looking at the SQL query.
I have an old C++ code which calls some library functions to access the Oracle database. The source code for the library is not available to me yet. The functions selects/updates/deletes and inserts based on some input parameters I give. I do not know which tables it affects. How do I find out the actual SQL query and/or the tables it accesses ? I was told about V$SQL table that
has the most recently executed queries, but
I did'nt see any queries connected to my process.
Could anybody help me on this ?
Thanks
Jagdeep
[email protected]
nullPRECISE/SQL can help you if you have access to it
2nd option can be that turn on SQL_TRACE
Run executable of ur c++ program
it will create a trace file in user_dump_dest
and then using TKPROF u can see all quesries and their plan also.
HTH
Gagan Deep Singh
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by (jagdeeps):
Hi,
I would like to know is there a way to find out what queries have been executed and on which tables without looking at the SQL query.
I have an old C++ code which calls some library functions to access the Oracle database. The source code for the library is not available to me yet. The functions selects/updates/deletes and inserts based on some input parameters I give. I do not know which tables it affects. How do I find out the actual SQL query and/or the tables it accesses ? I was told about V$SQL table that
has the most recently executed queries, but
I did'nt see any queries connected to my process.
Could anybody help me on this ?
Thanks
Jagdeep
[email protected]<HR></BLOCKQUOTE>
null -
HOW TO FIND AND CORRECT THE SQL QUERY ERRORS ????
Sometimes I get the errors while executing the sql queries.
I just wanted to know about the various ways by which I can find the sql query errors .
Any suggestions will be deeply appreciated.If you get the an error from SSMS and you can't comprehend it, you can google the error message and google would always lead you to the correction. Or you can post the error in this forum, people
here are always kind and ready to help :).
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Sql query to find answered and received calls for month or day
Hi experts !
1.Any one help in finding out the received, answered and missed ,transfered in / out calls in UCCE using SQL query for a particular month or day.
2. We have some custom report templetes defined , need to know , how can we write Sql query to get those values from custum reports.
due to some issues, cannot use webview .Hi,
there's no such thing as reporting "for a particular Team". Teams in ICM are for administration purposes only (to have grouping of agents). ICM does not count the number of calls received by "teams". If there is a report in Webview "by team", it's always by agent. Try to run the report against a team once and then try to remove certain agents from that team - you'll see the difference.
What you are looking for is either reporting by Agent or by Agent/Skill group combination.
Try to explore the
- Agent_Half_Hour
- Agent_Skill_Group_Half_Hour
- Skill_Group_Half_Hour
database views.
The database schema documents are here:
http://www.cisco.com/en/US/products/sw/custcosw/ps1844/prod_technical_reference_list.html
Good luck.
G. -
How to write a SQL query in SAP B1 2007 B with input parameters?
How to write a SQL query in SAP B1 2007 B with input parameters, on execution of which will ask for some input value from the user and the values will be selected from a list such as item list?
The syntax like
SELECT * FROM OITM T0 WHERE T0.ItemCode = '[%0\]'
Thanks,
Gordon
Maybe you are looking for
-
Files cannot be located from external hard drive.
I just moved all my iTunes content to my laptop from my external hard drive (that I had been previously using with my PC), thinking it would be available on both as long as I had the Hard Drive plugged in. When I got downstairs however, I found that
-
Scheduling problem in planned order.
Hi all, I have a problem in scheduling of planned orders. I had mentioned the following parameters. 1. Available capacity in the work center as 06:00:00 to 12:00:00 2.Set up time is 10mins in the routing. 3. The planned order qty is 100 nos. While do
-
i get a warning when i delete, add or change a file's extension. it is driving me crazy. I know when i have performed this action, is there a way to shut off the warning?
-
How to make a gif out of a movie clip?
So yeah... I'm an idiot when it comes to these things. How do I go about doing a gif of a small video? And... Could you do the explanation in a step by step guide please. Thanks
-
I am trying to format a text field to produce a percentage. Currently when I input 50 into the field, it produces 50.00% (rather than 50%). I am using a javascript that another member recommended, but I would like to know how I can remove the 2 deci