Skip to main content
680 votes
36 answers
701k views

Fetch the rows which have the Max value for a column for each distinct value of another 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. How do I do this in SQL? (Preferably Oracle....
Umang's user avatar
  • 6,835
1375 votes
16 answers
2.5m 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 (skip ...
Mathieu Longtin's user avatar
385 votes
16 answers
1.1m views

Update statement with inner join on Oracle

I have a query which works fine in MySQL, but when I run it on Oracle I get the following error: SQL Error: ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ...
user169743's user avatar
  • 4,267
200 votes
10 answers
642k views

ORA-00979 not a group by expression

I am getting ORA-00979 with the following query: SELECT cr.review_sk, cr.cs_sk, cr.full_name, tolist(to_char(cf.fact_date, 'mm/dd/yyyy')) "appt", cs.cs_id, cr.tracking_number from review cr, cs, fact ...
Theresa's user avatar
  • 3,645
16 votes
1 answer
3k views

How to describe performance issue in relational database?

I have a query running in a relational database that doesn't fulfill the expectation of the users. What information should I provide and what should I avoid, so that I can receive an effective help ...
Marmite Bomber's user avatar
24 votes
9 answers
146k views

Dynamic Pivot in Oracle's SQL

... pivot (sum(A) for B in (X)) Now B is of datatype varchar2 and X is a string of varchar2 values separated by commas. Values for X are select distinct values from a column(say CL) of same table. ...
prabhakar's user avatar
  • 415
533 votes
18 answers
1.4m views

How to create id with AUTO_INCREMENT on Oracle?

It appears that there is no concept of AUTO_INCREMENT in Oracle, up until and including version 11g. How can I create a column that behaves like auto increment in Oracle 11g?
Sushan Ghimire's user avatar
214 votes
10 answers
489k views

SQL Query to concatenate column values from multiple rows in Oracle

Would it be possible to construct SQL to concatenate column values from multiple rows? The following is an example: Table A PID A B C Table B PID SEQ Desc A 1 Have A 2 a ...
jagamot's user avatar
  • 5,434
22 votes
4 answers
41k views

Oracle SQL pivot query

I have data in a table as seen below: MONTH VALUE 1 100 2 200 3 300 4 400 5 500 6 600 I want to write a SQL query so that result is given as below: MONTH_JAN MONTH_FEB ...
code990's user avatar
  • 621
53 votes
22 answers
310k views

BadImageFormatException. This will occur when running in 64 bit mode with the 32 bit Oracle client components installed

I am getting this error while on of my .Net application are trying to make a connection to oracle database. The error says that This problem will occur when running in 64 bit mode with the 32 bit ...
user avatar
23 votes
7 answers
99k views

How to convert comma separated values to rows in oracle?

Here is the DDL -- create table tbl1 ( id number, value varchar2(50) ); insert into tbl1 values (1, 'AA, UT, BT, SK, SX'); insert into tbl1 values (2, 'AA, UT, SX'); insert into tbl1 values (3,...
Samiul Al Hossaini's user avatar
132 votes
14 answers
365k views

Splitting string into multiple rows in Oracle

I know this has been answered to some degree with PHP and MYSQL, but I was wondering if someone could teach me the simplest approach to splitting a string (comma delimited) into multiple rows in ...
marshalllaw's user avatar
  • 1,321
395 votes
9 answers
899k views

Best way to do multi-row insert in Oracle?

I'm looking for a good way to perform multi-row inserts into an Oracle 9 database. The following works in MySQL but doesn't seem to be supported in Oracle. INSERT INTO TMP_DIM_EXCH_RT (EXCH_WH_KEY, ...
jamz's user avatar
  • 5,301
232 votes
10 answers
178k views

When do I need to use a semicolon vs a slash in Oracle SQL?

We have been having some debate this week at my company as to how we should write our SQL scripts. Background: Our database is Oracle 10g (upgrading to 11 soon). Our DBA team uses SQLPlus in order ...
amischiefr's user avatar
  • 4,880
146 votes
19 answers
564k 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 ...
Chris Conway's user avatar
  • 16.5k

15 30 50 per page
1
2 3 4 5
816