Oracle Server is a relational DBMS (Database Management System) created by Oracle Corporation. Do NOT use this tag for other DBMS servers owned by Oracle (for instance MySQL, TimesTen and Berkeley DB).
197
votes
25answers
228k views
Fetch the row which has the Max value for a column
Table: UserId, Value, Date.
I want to get the UserId, Value for the max(Date) for each UserId. That is, the Value for each UserId that has the latest date. Is there a way to do this simply in SQL? ...
15
votes
7answers
22k views
Is there an Oracle SQL query that aggregates multiple rows into one row?
I have a table that looks like this:
A 1
A 2
B 1
B 2
And I want to produce a result set that looks like this:
A 1 2
B 1 2
Is there a SQL statement that will do this? I am using Oracle.
...
179
votes
8answers
181k views
How do I limit the number of rows returned by an Oracle query after ordering?
Is there a way to make an Oracle query behave like it contains a MySQL limit clause?
In MySQL, I can do this:
select *
from sometable
order by name
limit 20,10
to get the 21st to the 30th rows ...
25
votes
12answers
106k views
How can I combine multiple rows into a comma-delimited list in Oracle?
I have a simple query:
select * from countries
with the following results:
country_name
------------
Albania
Andorra
Antigua
.....
I would like to return the results in one row, so like this:
...
98
votes
13answers
27k views
Inner join vs Where
Is there a difference in performance (in oracle) between
Select * from Table1 T1
Inner Join Table2 T2 On T1.ID = T2.ID
And
Select * from Table1 T1, Table2 T2
Where T1.ID = T2.ID
?
45
votes
6answers
77k views
Oracle - Update statement with inner join
I have a query which works fine in MySQL, I'm trying to get it working on oracle but get the following error
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not ...
37
votes
6answers
15k views
What is the minimum client footprint required to connect C# to an Oracle database?
I have successfully connected to an Oracle database (10g) from C# (Visual Studio 2008) by downloading and installing the client administration tools and Visual Studio 2008 on my laptop.
The ...
83
votes
8answers
110k views
Oracle: how to UPSERT (update or insert into a table?)
The UPSERT operation either updates or inserts a row in a table, depending if the table already has a row that matches the data:
if table t has a row exists that has key X:
update t set ...
91
votes
8answers
28k views
Why does Oracle 9i treat an empty string as NULL?
I know that it does consider ' ' as NULL, but that doesn't do much to tell me why this is the case. As I understand the SQL specifications, ' ' is not the same as NULL -- one is a valid datum, and ...
6
votes
12answers
20k views
How do I Create a Comma-Separated List using a SQL Query?
I have 3 tables called:
Applications (id, name)
Resources (id, name)
ApplicationsResources (id, app_id, resource_id)
I want to show on a GUI a table of all resource names. In one cell in each row ...
34
votes
11answers
83k views
Search All Fields In All Tables For A Specific Value (Oracle)
Is it possible to search every field of every table for a particular value in Oracle?
There are hundreds of tables with thousands of rows in some tables so I know this could take a very long time to ...
64
votes
9answers
49k views
Can you use Microsoft Entity Framework with Oracle?
Is it possible to use Microsoft Entity Framework with Oracle database?
266
votes
7answers
443k views
Get list of all tables in Oracle?
How do I query an Oracle database to display the names of all tables in it?
21
votes
7answers
26k views
Removing duplicate rows from table in Oracle
I'm testing something in Oracle and populated a table with some sample data, but in the process I accidentally loaded duplicate records, so now I can't create a primary key using some of the columns.
...
4
votes
5answers
6k views
Using 'case expression column' in where clause
SELECT ename
, job
, CASE deptno
WHEN 10
THEN 'ACCOUNTS'
WHEN 20
THEN 'SALES'
ELSE 'UNKNOWN'
END AS department
FROM emp /* !!! */
...