Beginners problem- having/where
I need to find the model that have maximum number of units
I wrote:
select model , MODEL_COUNT as model_counter from (
select model , count (*) as MODEL_COUNT
from Airplanes group by model)
where MODEL_COUNT = max(MODEL_COUNT);
and got:
ORA-00934: group function is not allowed here
So I changed the where to having:
select model , MODEL_COUNT as model_counter from (
select model , count (*) as MODEL_COUNT
from Airplanes group by model)
having MODEL_COUNT = max(MODEL_COUNT);
and got:
ORA-00979: not a GROUP BY expression
What to do???
Hi and welcome to the forum.
What to do???Well, you could use the row_number analytic here:
select model
, model_count model_counter
from ( select model
, count (*) model_count
, row_number() over ( order by count(*) desc) rn
from airplanes
group by model
where rn=1;See:
http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html
http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
for some more in-depth explanations.
And keep in mind that all Oracle Documentation (and examples) can be found @ http://tahiti.oracle.com
Similar Messages
-
Problem having the cloumn fields in the heading(REP:1317)
Hi
I am having a problem having a column field in the Header.I followed the instructions in the help i.e creating a field and then referencing it with a boiler text(&<field name>).But When I run the report I get the error message
"REP-1317: Boilerplate '<boilerplate name>' references field with source '<column name>' at wrong frequency."
How do I set these two field in the same frequency.
Can anybody help.
ThanksHi
See my answer at YOUR topic "Unable to have the column fields in the header".
Once more: the only way to solve the problem is to create in the Header the Repeating Frame linking with the group of "<field name>". Then it's possible to place Field to be referenced by "database_col" or boiler text such as "&<field name>".
Andrew. -
Is it a problem having two different Ipod accounts on the same computer?
I have just bought an Ipod Nano for my wife. I have a 30 Gb Ipod my self.
My question is:
Is it a problem, having two different Ipod accounts on the same computer?
Are there something I should be aware of before connecting the second Ipod?
Windows XPhiya!
these resources might be of some help with your questions:
Natalie Beresford: multiple iPod/iTunes installations
How to use multiple iPods with one computer
iTunes: How to share music between different accounts on a single computer
love, b -
Perhaps the problem lies in the version of the Word file. Does anyone know what versions Pages 09 will accept? I have re-installed iWorks09, but that did not solve the problem. My operating system is 10.6.8 and I am current on updates.
The Word 2 doc is ancient. I wouldn't even know where to find one to test.
The obvious thing to test is open the documents you previously opened successfully.
If they still open successfully, then it is highly likely that the version that is the problem.
Peter -
HT204053 i have old macbook pro and having problem finding where to down load icloud
How do add icloud to my Macbook pro wher do i go?
Welcome to the Apple community.
iCloud comes with OSX 10.7.2 or later, you need to update your operating system from the Mac App Store. OSX 10.9 is the current version. -
Recently my shift key has been for some unknown reason ben typing capital "y" when I use it, and YYI don't know how to stop it. Also my return key has been adding a backslash after the return, and I am unsure how to remove that as well, I had this problem aout 6 months ago, and I had to wipe the drive and do a clean install before it fixed. I would not want to do that again, if at all possible.
Have You found a fix for this(question mark)
-
I want to uninstall Firefox 3.6.8 because of a problem I am having and then once I do that I will reinstall it. My problem is I don't want to lose my Bookmarks. Can someone please tell me where they are filed so I can make a backup copy before I do any uninstalling. Thanks, John
Bookmarks and other personal data are located in your Profile folder. See:<br />
* http://support.mozilla.com/en-US/kb/Profiles
* https://support.mozilla.com/en-US/kb/Backing+up+your+information
* http://support.mozilla.com/en-US/kb/Profiles#How_to_find_your_profile
* http://kb.mozillazine.org/Show_hidden_files_and_folders
* http://support.mozilla.com/en-US/kb/Recovering+important+data+from+an+old+profile
* http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox
When un-installing Firefox be sure that the box specified in Item 7 of the article below (and the image that I have attached) is NOT checked:
*Uninstalling Firefox: http://support.mozilla.com/en-US/kb/uninstalling+Firefox -
PL/SQL Evaluation problem of where clause in case of NUMBER column type
I found the following problem in Oracle® Database 2 Day Developer's Guide 11g Release 1 (11.1) B28843-04:
The sole parameter of function eval_frequency is employee_id IN employees.employee_id%TYPE.
An ORA-01422 exception occurs when the execution reaches the following select command
SELECT e.hire_date
INTO hire_date
FROM employees e
WHERE employee_id= e.employee_id;
A possible cause of the error is that the type of employee_id is NUMBER while the employees.employee_id is NUMBER(6,0) . The result of the selection is the same as there were no WHERE clause at all.
Everything worked fine, when I declared a temporary variable of NUMBER(6,0) for storing the actual parameter of function and used this variable in the where clause, but I consider this "solution" as being no solution.
It is pointless to use %TYPE parameter of a function for flexibility if I must degrade this flexibility by a fixed declaration of a temporary variable of the same type as the column in question.
What is wrong?
The Developer'Guide I used, the Oracle Sql Developer I used or the PL/SQL version ?Hi,
Welcome to the forum!
user8949829 wrote:
A possible cause of the error is that the type of employee_id is NUMBER while the employees.employee_id is NUMBER(6,0) . The result of the selection is the same as there I don't think so. The variable employee_id is defined as having the exact same type as the eponymous column. Even if it didn't, I believe Oracle will always implicity convert between datatypes when possible, rounding if necessary. That may cause errors, but it isn't causing this error.
No, the error has nothing to do with the data type. It has to do with the ambiguity of employee_id: is it a column, or is it a variable?
The default is that it means the column name, so
WHERE employee_id = e.employee_idis equivalent to saying
WHERE e.employee_id = e.employee_idwhich isn't quite the same thing as not having a WHERE clause; rows with NULL employee_id would still be excluded, if there were any.
I think it's best not to use variable names that are the same as column names. You could call the variable v_employee_id, or, since it's an IN-argument, in_employee_id.
If you must use a variable that can be mistaken for a column, then qulaify it with the name of the procedure, like this:
WHERE eval_frequency.employee_id = e.employee_id
Everything worked fine, when I declared a temporary variable of NUMBER(6,0) for storing the actual parameter of function That makes sens. You probably gave that variable a name that couldn't be mistaken for a column in the table.
Edited by: Frank Kulash on Jan 12, 2011 8:27 PM -
PreparedStatement.setDate(int, Date) problem in WHERE clause
Hello all,
First and foremost, thanks for the help. It is really appreciated.
I am having the toughest time tracking down a problem with how I am handling date setting with my PreparedStatement. The kicker is that I am only having problems with the where clause date sets.
The date is pulled out of the database, put into a string, modified, put back into a date, and then used to query via SQL.
Data selected this way:
"SELECT * FROM table_name"
Data updated this way:
"UPDATE table_name SET name = ? WHERE pk_id = ? AND pk_date = ?"
The java.sql.Date object I use to PreparedStatement.setDate(int, Date) is exact to seconds. It works great if it is not in the where clause (eg Inserts work, Updates work without where clause) which leads me to believe there is truncation of data somewhere between setDate(int, Date) and the native SQL in Oracle 9i.
Is that a correct assumption? How do I solve this?
Thanks,
JohnMy assumption was correct. If a java.sql.DATE is pulled from a Oracle 9i database it may have more data in it than is allowed for in java.sql.Date. java.sql.Timestamp, on the other hand, does retain all data in the field.
The correct code looks something like this
prepStmt.setTimestamp(Timestamp.valueOf(timeString));
cheers,
John -
Whenever I send a file to my Xerox C75 from my Mac (Yosemite), the file goes to the printer okay, then InDesign crashes.
I think there is a patch specifically for this issue. Where do I find it?Yes, I have Fiery Hot Folders Console. That is certainly an alternative that should work as I can then avoid having to choose Fiery Features from the print dialog box in order to choose the paper tray and other features I need.
I am about to try a clean install of OS 10.9.3, and I am not the least bit happy about it. Adobe CC is my main set of go-to applications for my work, and those are the only applications that give me ANY problems with printing. I have forked out real money on different versions since I started using Adobe in the late 1990's, and my troubles seem to increase with every new release. -
Problem having ATV (1G) audio play to Airport Express connected speakers
I've had some difficulties trying to have my ATV (1st Gen) act as a jukebox and play its audio on speakers connected to an Airport Express. When I select the remote speakers on the ATV it attempts to connect to them, spins for a while, and then gives up. The same speakers work fine if I remotely connect to them from a Mac running iTunes instead. I'd really like to use this feature with the ATV since it is always on and I can control it from anywhere on my network using my iPhone.
Anyone else having any success using the ATV to play to remote speakers?You are mistaken. The Apple TV (1st Gen) can stream music to an Airport Express over AirTunes. It is selectable in the ATV settings display, and in the Apple Remote iPhone application, and I've successfully done it before. However, it does not always connect to the speakers properly, whereas a Mac running iTunes has no problem.
-
Urgent: Performance problem with where clause using IN and an OR condition
Select statement is:
select fl.feed_line_id
from ap_expense_feed_lines_all fl
where ((:1 is not null and
fl.feed_line_id in (select distinct r2.object_id
from xxdl_pcard_wf_routing_lists r2,
per_people_f hr2
where upper(hr2.full_name) like upper(:1||'%')
and hr2.person_id = r2.person_id
and r2.fyi_list is null
and r2.sequence_number <> 0))
or
(:1 is null))
If I modify the statement to remove the "or (:1 is null))" part at the bottom of the where clause, it returns in .16 seconds. If I modify the statement to only contain the "(:1 is null))" part of the where clause, it returns in .02 seconds. With the whole statement above, it returns in 477 seconds. Anyone have any suggestions?
Explain plan for the whole statement is:
(1) SELECT STATEMENT CHOOSE
Est. Rows: 10,960 Cost: 212
FILTER
(2) TABLE ACCESS FULL AP.AP_EXPENSE_FEED_LINES_ALL [Analyzed]
(2) Blocks: 8,610 Est. Rows: 10,960 of 209,260 Cost: 212
Tablespace: APD
(6) TABLE ACCESS BY INDEX ROWID HR.PER_ALL_PEOPLE_F [Analyzed]
(6) Blocks: 4,580 Est. Rows: 1 of 85,500 Cost: 2
Tablespace: HRD
(5) NESTED LOOPS
Est. Rows: 1 Cost: 4
(3) TABLE ACCESS FULL XXDL.XXDL_PCARD_WF_ROUTING_LISTS [Analyzed]
(3) Blocks: 19 Est. Rows: 1 of 1,303 Cost: 2
Tablespace: XXDLD
(4) UNIQUE INDEX RANGE SCAN HR.PER_PEOPLE_F_PK [Analyzed]
Est. Rows: 1 Cost: 1
Thanks in advance,
PeterThanks for the reply, but I have already checked what you are suggesting and I am pretty sure those are not causing the problem. The hr2.full_name column has an upper index and the (4) line of the explain plan shows that index being used. In addition, that part of the query executes on its own quickly.
Because the sql is not displayed in an indented format on this page it is a little hard to understand the structure so I am going to restate what is happening.
My sql is:
select a_column
from a_table
where ((:1 is not null) and a_column in (sub-select statement)
or
(:1 is null))
The :1 bind variable is set to a varchar2 entered on the screen of an application.
If I execute either part of the sql without the OR condition, performance is good.
If the :1 bind variable is null with the whole sql statement (so all rows or a_table are returned), performance is still good.
If the :1 bind variable is a not-null value with the whole sql statement, performance stinks.
As an example:
where (('wa' is not null) and a_column in (sub-select statement)) -- fast
where (('wa' is null)) -- fast
where (('' is not null) and a_column in (sub-select statement) -- fast
or
('' is null))
where (('wa' is not null) and a_column in (sub-select statement) -- slow
or
('wa' is null)) -
I was having an issue a few months back with one of my user accounts, and the only solution was to create a new user. But I couldn't for the life of me figure out how to get my iWeb site to tranfer to the new user. So my workaround was to create new pages under the new user, and go back into the old user only when I absolutely had to make changes. This worked fine since November, but now I see that my newer site -- which is a subsite to my main domain -- is now defaulting as the main page on my website. This is bad!
How can I merge my iWeb sites from the two users so I can avoid this problem? I realize that Mobile Me is going away, but I'm hoping to solve this problem today.To merge your sites, use iWebSites.
Download and movie here :
http://www.wyodor.net/_Demo/Aptana/iWebSites.html -
Problems with WHERE CLAUSE in selects executed by BAPIs
Dear Experts,
I'm trying to make a SAP Java Connector. My problem is that, when they are called by Java, BAPI functions don't run in the same manner as in SAP testing mode .
I tested two BAPI functions called through my connector and I saw with the debbuger that BAPI functions don't execute the select and loop at with a WHERE clause when they are called by Java, therefore they throw errors. But in the SAP testing mode functions work just fine.
I'm new to SAP and I don't know why this happens. Would you like to explain to me how to fix this problem?
Thank you very much.
Kind regards,
Maricica979380 wrote:
Yeah,i m sorry.I m a forum newbie.All right,we ve been given an oracle account for the purpose of this project,an we have connect to the oracle database either via linux terminal with sqlplus,or via oracle client and plsql.So i have to create some tables,then fill these tables with tuples(we ve been given fixed .sql files to do that),and we re suggested to do that from the linux terminal.I did that successfully.Then we have to run some queries either in terminal or plsql.I chose plsql.I connect,i can see the tables that i have created but when i run(in both sql and terminal window) for example the query "select * from table_1",i take 0 rows as a result.I tested to run the query from terminal(with sqlplus) to see if the tables are really empty,but i recieve the results as i should.
I am sorry for my chaotic writing but i cant even explain the problem to myself better and i m not a native.
(im using oracle version 11.2.0.1, this is the first time i m using oracle databases and i m a rookie in databases in general)
Edited by: 979380 on 1 Ιαν 2013 10:33 πμ
[oracle@localhost ~]$ sqlplus user1/user1
SQL*Plus: Release 11.2.0.2.0 Production on Tue Jan 1 11:19:29 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table table_1 (id number);
Table created.
SQL> select * from table_1;
no rows selected
SQL> insert into table_1 values(1);
1 row created.
SQL> select * from table_1;
ID
1
SQL> in order to SELECT any rows from any table, first you must INSERT data into the table!
is COPY & PASTE broken for you? -
Performace tuning required in queries having where clause on = or =
Hi,
I ahve query which is taking hell lot of time because of having filter condition on with >=.
Say:
select * from <tableA> where <column1> >= sysdate;
By any chance can we do something to avoid full scan on above table?Hi,
The oracle version is :
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
the query is :
with temp as(
select sysdate as valuedate from dual
union
select sysdate+1 as valuedate from dual
Union
select sysdate+2 as valuedate from dual
Union
select sysdate+3 as valuedate from dual
select valuedate from temp where valuedate >= sysdate
Taking the above scenerio, is it possible to build any index which can be used to improve the performance.
The above query is just a example. the original query is fetching data from huge table with filter condition >=
I want my index to be used there.
Maybe you are looking for
-
Internet connection dropping this week
Internet disconnecting on a daily basis since Tuesday 9 June: This week, my internet connection appears to have developed an intermittent disconnection issue. Below are the details and what I've done about it. So far at time of writing this, Sky have
-
Hi I'm trying to update my apps using the creative cloud desktop app. I can't see any apps in the app tab, the wheel just spins round and round and nothing happens. Has anyone got any ideas? I've tried uninstalling the desktop app and reinstalling bu
-
Acrobat 8 Pro with FormDesigner crashing
Have a user running Acrobat 8 Professional who is attempting to create a form with the FormDesigner, but when she clicks over to the Preview tab, an error pops up stating that Acrobat.exe has encountered an error and needs to close. The FormDesigner
-
hi, I am facing a problem in sending mail. My program is running on a linux operating system and Tomcat 5.5 . So my problem is that when I try to execute that program I get the FOLLOWING EXCEPTION. I am not getting why that exception is occuring. jav
-
How do I get the pictures of CDs to show up?
The IPod nano says that pictures of the music you are playing are supposed to show up (pictures of what the CD cover looks like). Does anyone know how I can get them to show up?