I use SqlPlus.
There is a lot of solutions and examples out there for related problems, but I haven't been able to fix my issue.
Expected result: 1 line that gives information about a library member that borrowed a book for the longest time. (displaying the amount of time: ex. Johnson John has ...: 31 days)
My current query:
SELECT DISTINCT m.firstname || ' ' || m.lastname || ' has borrowed for the longest time: ' || ROUND(MAX(l.date_of_return - l.date_borrowed)) || ' days' "Longest time borrowed"
FROM loans l
JOIN members m
ON l.memberid = m.memberid
WHERE l.date_of_return - l.date_borrowed = (SELECT MAX(date_of_return - date_borrowed) FROM loans)
/
Tables used:
LOANS:
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
ISBN NOT NULL VARCHAR2(20)
SERIAL_NO NOT NULL NUMBER(2)
DATE_BORROWED NOT NULL DATE
DATE_OF_RETURN DATE
MEMBERID NOT NULL VARCHAR2(11)
EXTEND VARCHAR2(5)
MEMBERS:
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
MEMBERID NOT NULL VARCHAR2(11)
LASTNAME NOT NULL VARCHAR2(20)
FIRSTNAME VARCHAR2(20)
Error:
ERROR at line 1: ORA-00937: not a single-group group function
I think I'm overlooking a simple solution. Thanks in advance.
Try
SELECT m.firstname || ' ' || m.lastname || ' has borrowed for the longest time: ' || ROUND(l.date_of_return - l.date_borrowed) || ' days' "Longest time borrowed"
FROM loans l
JOIN members m
ON l.memberid = m.memberid
WHERE l.date_of_return - l.date_borrowed = (SELECT MAX(l2.date_of_return - l2.date_borrowed) FROM loans l2)
AND ROWNUM <=1
You might want to avoid the additional calculation based comparison outside of the inner select (which would likely end up as an additional loop over loans during execution significantly stretching the run time).
It should be possible to collect the id inside the inner select as well as the calculation result and use it outside.
Try something like this:
SELECT m.firstname, m.lastname, b.maxtime
FROM members m, loans l
INNER JOIN (
SELECT li.memberid id, MAX(li.date_of_return - li.date_borrowed) maxtime
FROM loans li
GROUP BY li.memberid
) b ON m.memberid = b.id
ORDER BY b.maxtime
BTW: There's a pretty good post covering similar topics here (just in case you haven't found this one while searching), which might contain some interesting ideas for what you're trying to do: SQL select only rows with max value on a column
Related
I am trying to summarize some massive tables in a way that can help me investigate further for some data issues. There are hundreds of 1000s of rows, and roughly 80+ columns of data in most of these tables.
From each table, I have already performed queries to throw out any columns that have all nulls or 1 value only. I've done this for 2 reasons.... for my purposes, a single value or nulls in the columns are not interesting to me and provide little information about the data; additionally, the next step is that I want to query each of the remaining columns and return up to 30 distinct values in each column (if the column has more than 30 distinct values, we show the 1st 30 distinct values).
Here is the general format of output I wish to create:
Column_name(total_num_distinct): distinct_val1(val1_count), distinct_val2(val2_couunt), ... distinct_val30(val30_count)
Assuming my data fields are integers, floats, and varchar2 data types, this is the SQL I was trying to use to generate that output:
declare
begin
for rw in (
select column_name colnm, num_distinct numd
from all_tab_columns
where
owner = 'scz'
and table_name like 'tbl1'
and num_distinct > 1
order by num_distinct desc
) loop
dbms_output.put(rw.colnm || '(' || numd || '): ');
for rw2 in (
select dis_val, cnt from (
select rw.colnm dis_val, count(*) cnt
from tbl1
group by rw.colnm
order by 2 desc
) where rownum <= 30
) loop
dbms_output.put(rw2.dis_val || '(' || rw2.cnt || '), ');
end loop;
dbms_output.put_line(' ');
end loop;
end;
I get the output I expect from the 1st loop, but the 2nd loop that is supposed to output examples of the unique values in each column, coupled with the frequency of their occurrence for the 30 values with the highest frequency of occurrence, appears to not be working as I intended. Instead of seeing unique values along with the number of times that value occurs in the field, I get the column names and count of total records in that table.
If the 1st loop suggests the first 4 columns in 'tbl1' with more than 1 distinct value are the following:
| colnm | numd |
|----------------|
| Col1 | 2 |
| Col3 | 4 |
| Col7 | 17 |
| Col12 | 30 |
... then the full output of 1st and 2nd loop together looks something like the following from my SQL:
Col1(2): Col1(tbl1_tot_rec_count), Col3(tbl1_tot_rec_count)
Col3(4): Col1(tbl1_tot_rec_count), Col3(tbl1_tot_rec_count), Col7(tbl1_tot_rec_count), Col12(tbl1_tot_rec_count)
Col7(17): Col1(tbl1_tot_rec_count), Col3(tbl1_tot_rec_count), Col7(tbl1_tot_rec_count), Col12(tbl1_tot_rec_count), .... , ColX(tbl1_tot_rec_count)
Col12(30): Col1(tbl1_tot_rec_count), Col3(tbl1_tot_rec_count), Col7(tbl1_tot_rec_count), Col12(tbl1_tot_rec_count), .... , ColX(tbl1_tot_rec_count)
The output looks cleaner when real data is output, each table outputting somewhere between 20-50 lines of output (i.e. columns with more than 2 values), and listing 30 unique values for each field (with their counts) only requires a little bit of scrolling, but isn't impractical. Just to give you an idea with fake values, the output would look more like this with real data if it was working correctly (but fake in my example):
Col1(2): DisVal1(874,283), DisVal2(34,578),
Col3(4): DisVal1(534,223), DisVal2(74,283), DisVal3(13,923), null(2348)
Col7(17): DisVal1(54,223), DisVal2(14,633), DisVal3(13,083), DisVal4(12,534), DisVal5(9,876), DisVal6(8,765), DisVal7(7654), DisVal8(6543), DisVal9(5432), ...., ...., ...., ...., ...., ...., ...., DisVal17(431)
I am not an Oracle or SQL guru, so I might not be approaching this problem in the easiest, most efficient way. While I do appreciate any better ways to approach this problem, I also want to learn why the SQL code above is not giving me the output I expect. My goal is trying to quickly run a single query that can tell me which columns have interesting data I might what to examine further in that table. I have probably 20 tables I need to examine that are all of similar dimensions and so very difficult to examine comprehensively. Being able to reduce these tables in this way to know what possible combinations of values may exist across the various fields in each of these tables would be very helpful in further queries to deep dive into the intricacies of the data.
It's because the select rw.colnm dis_val, count(*) cnt from tbl1 group by rw.colnm order by 2 desc is not doing at all what you think, and what you think to be done can't be done without dynamic SQL. What it does is in fact select 'a_column_of_tabl1' dis_val, count(*) cnt from tbl1 group by 'a_column_of_tabl1' order by 2 desc and what you need to do is execute dynamically the SQL: 'select ' || rw.colnm || ' dis_val, count(*) cnt from tbl1 group by ' || rw.colnm || ' order by 2 desc'.
Here is the (beta) query you can use to get the SQL to execute:
(I tested with user_* VIEWs instead of ALL_* to avoid getting to many results here...)
select utc.table_name, utc.column_name,
REPLACE( REPLACE(q'~select col_name, col_value, col_counter
from (
SELECT col_name, col_value, col_counter,
ROW_NUMBER() OVER(ORDER BY col_counter DESC) AS rn
FROM (
select '{col_name}' AS col_name,
{col_name} AS col_value, COUNT(*) as col_counter
from {table_name}
group by {col_name}
)
)
WHERE rn <= 30~', '{col_name}', utc.column_name), '{table_name}', utc.table_name) AS sql
from user_tab_columns utc
where not exists(
select 1
from user_indexes ui
join user_ind_columns uic on uic.table_name = ui.table_name
and uic.index_name = ui.index_name
where
ui.table_name = utc.table_name
and exists (
select 1 from user_ind_columns t where t.table_name = ui.table_name
and t.index_name = uic.index_name and t.column_name = utc.column_name
)
group by ui.table_name, ui.index_name having( count(*) = 1 )
)
and not exists(
SELECT 1
FROM user_constraints uc
JOIN user_cons_columns ucc ON ucc.constraint_name = uc.constraint_name
WHERE constraint_type IN (
'P', -- primary key
'U' -- unique
)
AND uc.table_name = utc.table_name AND ucc.column_name = utc.column_name
)
;
This is my first time working with the LISTAGG function and I'm confused. I can select the data easily enough, but the characters of the USERS column all have spaces in between them, and when trying to copypaste it, no data from that column is copied. I've tried with two different IDEs. Am I doing something wrong?
Example:
select course_id, listagg(firstname, ', ') within group (order by course_id) as users
from (
select distinct u.firstname, u.lastname, u.student_id, cm.course_id
from course_users cu
join users u on u.pk1 = cu.users_pk1
join course_main cm on cm.pk1 = cu.crsmain_pk1
and cm.course_id like '2015SP%'
)
group by course_id;
Yields:
I had similar problem, it turned out that the problem was with encoding. I got this solved like this (change to another encoding if needed):
...listagg(convert(firstname, 'UTF8', 'AL16UTF16'), ', ')...
Your firstname column seems to be defined as nvarchar2:
with t as (
select '2015SP.BOS.PPB.556.A'as course_id,
cast('Alissa' as nvarchar2(10)) as firstname
from dual
union all select '2015SP.BOS.PPB.556.A'as course_id,
cast('Dorothea' as nvarchar2(10)) as firstname
from dual
)
select course_id, listagg(firstname, ', ')
within group (order by course_id) as users
from t
group by course_id;
COURSE_ID USERS
-------------------- ------------------------------
2015SP.BOS.PPB.556.A
... and I can't copy/paste the users values from SQL Developer either, but it displays with spaces, as you can see from SQL*Plus:
COURSE_ID USERS
-------------------- ------------------------------
2015SP.BOS.PPB.556.A A l i s s a, D o r o t h e a
As the documentation says, the listagg() function always returns varchar2 (or raw), so passing in an nvarchar2 value causes an implicit conversion which is throwing out your results.
If you're stuck with your column being of that data type, you could cast it to varchar2 inside the listagg call:
column users format a30
with t as (
select '2015SP.BOS.PPB.556.A'as course_id,
cast('Alissa' as nvarchar2(10)) as firstname
from dual
union all select '2015SP.BOS.PPB.556.A'as course_id,
cast('Dorothea' as nvarchar2(10)) as firstname
from dual
)
select course_id, listagg(cast(firstname as varchar2(10)), ', ')
within group (order by course_id) as users
from t
group by course_id;
COURSE_ID USERS
-------------------- ------------------------------
2015SP.BOS.PPB.556.A Alissa, Dorothea
But you probably don't really want it to be nvarchar2 at all.
Apparently it's a known (unresolved?) bug in 11. TO_CHAR() worked for me...
SELECT wiporderno, LISTAGG(TO_CHAR(medium), ',') WITHIN GROUP(ORDER BY wiporderno) AS jobclassification
...where medium was the problematic column/data type.
I use ADO database in Delphi 2010 (TADOQuery).
The destination is to find the available rooms and show its room rate for a small INN.
t_room
coderoom as string
coderoomtype as string
t_typeroom
coderoomtype as string
nameroomtype as string
priceroomtype as number
t_trans
datetrans as date
codepoeple as string
coderoom as string
dateintrans as date -> date check in
dateouttrans as date -> date check out
Currently I use the query below to show the room prices.
SELECT
t_room.coderoom, t_room.coderoomtype, t_roomtype.coderoomtype,
t_roomtype.nameroomtype, t_roomtype.priceroomtype
FROM
t_room
INNER JOIN
t_roomtype ON t_room.coderoomtype = t_roomtype.coderoomtype
ORDER BY
t_room.coderoom ASC;
And manage to show : (in ADOQuery1 and DBGrid1 in Delphi 2010)
coderoom | nameroomtype | priceroomtype
----------------------------------------
101 | VIP | 20
102 | VIP | 20
103 | Standart | 10
104 | Standart | 10
105 | Standart | 10
106 | Standart | 10
What I want to do is how to show the coderoom s that has not been booked or has not been checkedin within t_trans ? (for specific dates)
Maybe something like below (using NOT IN operator) :
SELECT
t_room.coderoom, t_room.coderoomtype, t_room.notesroom,
t_roomtype.coderoomtype, t_roomtype.nameroomtype, t_roomtype.priceroomtype
FROM
t_room
INNER JOIN
t_roomtype ON t_room.coderoomtype = t_roomtype.coderoomtype
WHERE
t_room.coderoom NOT IN (SELECT *
FROM t_trans
WHERE [current book/checkin/out date not between dateintrans and dateoutrans]
ORDER BY coderoom ASC)
ORDER BY
t_room.coderoom ASC;
The question is how to find available rooms that aren't booked between the t_trans.datein and t_trans.dateout ?
I add some files to make it easy to understand what I want to do at : http://sidhiciang.com/myfiles/TRIAL%20Available%20Rooms.rar
When I use the code below return error : $7701C41F - Exception class EOleException with message "You have writen a subquest that can return more than one field without using EXISTS reserved word in the main query's FROM clause. Revise the SELECT statement of the subquery to request only one field."
The code are :
AQRoomAvailable1.SQL.Text := 'SELECT t_room.coderoom, t_room.coderoomtype, t_room.notesroom, t_roomtype.coderoomtype, t_roomtype.nameroomtype, t_roomtype.priceroomtype ';
AQRoomAvailable1.SQL.Text := AQRoomAvailable1.SQL.Text + 'FROM t_room INNER JOIN t_roomtype ON t_room.coderoomtype = t_roomtype.coderoomtype WHERE t_room.coderoom ';
AQRoomAvailable1.SQL.Text := AQRoomAvailable1.SQL.Text + 'NOT IN (SELECT * FROM t_trans x WHERE x.coderoom = t_room.coderoom AND ( (x.dateintrans BETWEEN ' + DateToStr(dtpDateIn1.Date) + ' AND ' + DateToStr(dtpDateOut1.Date) + ' ) ';
AQRoomAvailable1.SQL.Text := AQRoomAvailable1.SQL.Text + 'OR (x.dateouttrans BETWEEN ' + DateToStr(dtpDateIn1.Date) + ' AND ' + DateToStr(dtpDateOut1.Date) + ' ) ';
AQRoomAvailable1.SQL.Text := AQRoomAvailable1.SQL.Text + 'OR (' + DateToStr(dtpDateIn1.Date) + ' BETWEEN x.dateintrans AND x.dateouttrans) ) )';
I already read links below and did not find the answer and gotten more confused....
check availability of a room with SQL
mysql hotel room availability
listing rooms available[hotel reservation]
query for available rooms in hotel reservation
Select available rooms
selecting room type on room availabilty subquery
Room Booking Query
Room booking sql query
SQL Scheduling - Select All Rooms Available for Given Date Range
SQL Inner-join with 3 tables?
How can I join multiple SQL tables using the IDs?
SQL Query NOT Between Two Dates
The SQL does not seem to the main problem in this question. To find all lapping ranges you will have to differentiate 4 cases, where case 2 is a special case of case 1 or 3.
EE between SW and EW
already caught by case 1 and 3
SE between SW and EW
SW between SE and EE
If you want to use parameters for you query, which you should, it is depending from you database engine if you are able to declare variables in your SQL to avoid the need of using more parameters than needed. An example SQL could look like (depending of the way you are stroring end and start days you might need to add/subtract an offest to your parameters):
Declare #SW datetime
Declare #EW datetime
Select #SW=:SW
Select #EW=:EW
SELECT
t_room.coderoom, t_room.coderoomtype,
t_roomtype.coderoomtype, t_roomtype.nameroomtype, t_roomtype.priceroomtype
FROM
t_room
INNER JOIN
t_roomtype ON t_room.coderoomtype = t_roomtype.coderoomtype
WHERE
t_room.coderoom NOT IN (SELECT x.coderoom
FROM t_trans x
WHERE
(x.dateouttrans between #SW and #EW )
OR (x.dateintrans between #SW and #EW )
OR (#SW between x.dateintrans and x.dateouttrans)
)
ORDER BY
t_room.coderoom ASC;
EDIT to answer from the comment
Since Access is not capable to use local variables you will have to use 5 parameters, you should not try to create the SQL without parameters. The SQL of AQRoomAvailable1 would look like:
SELECT
t_room.coderoom, t_room.coderoomtype,
t_roomtype.coderoomtype, t_roomtype.nameroomtype, t_roomtype.priceroomtype
FROM
t_room
INNER JOIN
t_roomtype ON t_room.coderoomtype = t_roomtype.coderoomtype
WHERE
t_room.coderoom NOT IN (SELECT x.coderoom
FROM t_trans x where
(x.dateouttrans between :SW and :EW )
OR (x.dateintrans between :SW1 and :EW1 )
OR (:SW2 between x.dateintrans and x.dateouttrans)
)
ORDER BY
t_room.coderoom ASC;
Change the datatype of the parameters to ftDateTime:
Change your Action actRoomCheckIn1 to:
procedure TFMain.actRoomCheckIn1Execute(Sender: TObject);
begin
if (dtpDateOut1.Date >= dtpDateIn1.Date) then
begin
AQRoomAvailable1.Close;
AQRoomAvailable1.Parameters.ParamByName('SW').Value := dtpDateIn1.Date;
AQRoomAvailable1.Parameters.ParamByName('EW').Value := dtpDateOut1.Date;
AQRoomAvailable1.Parameters.ParamByName('SW1').Value := dtpDateIn1.Date;
AQRoomAvailable1.Parameters.ParamByName('EW1').Value := dtpDateOut1.Date;
AQRoomAvailable1.Parameters.ParamByName('SW2').Value := dtpDateIn1.Date;
AQRoomAvailable1.Open;
end
else
begin
AQRoomAvailable1.Active := False;
end;
end;
Two observations:
It's normal to use integers as primary (and foreign) keys and not strings, as you are doing here
It's not clear to me what the difference is between t_trans.datetrans, t_trans.dateintrans and t_trans.dateouttrans.
If dateintrans is the beginning of the booking and dateouttrans is the end, then the query you need is probably the following
SELECT t_room.coderoom
from t_room
where not exists (select 1 from t_trans
where t_trans.coderoom = t_room.coderoom
and t_trans.dateintrrans >= :p1
and t_trans.dateouttrans <= :p1)
:p1 is the date that which you wish to check.
My problem requires me to query data from the table, and include a column to calculate the % increase as well. I need to pull only the records with the highest % of increase using MAX. I think I'm on the right track but but for some reason its returning all records despite the having clause calling for just the max.
Select
O.Grocery_Item,
TO_CHAR(sum(g.Price_IN_2000), '$99,990.00') TOTAL_IN_2000,
TO_CHAR(sum(g.Estimated_Price_In_2025), '$99,990.00') TOTAL_IN_2025,
TO_CHAR(Round(O.MY_OUTPUT),'9,990') || '%' as My_Output
From
GROCERY_PRICES g,
(SELECT
GROCERY_ITEM,
(((sum(Estimated_Price_In_2025) -
sum(Price_IN_2000))/sum(Price_IN_2000))*100) MY_OUTPUT
FROM
GROCERY_PRICES
GROUP BY GROCERY_ITEM) O
Where
G.GROCERY_ITEM = O.GROCERY_ITEM
GROUP BY
O.GROCERY_ITEM, O.MY_OUTPUT
Having
my_output IN (select Max(O.MY_OUTPUT) from GROCERY_PRICES);
Results:
GROCERY_ITEM TOTAL_IN_2000 TOTAL_IN_2025 MY_OUTPUT
------------------------------ ------------- ------------- ---------
M_004 $2.70 $5.65 109%
B_001 $0.80 $2.64 230%
T_006 $5.70 $6.65 17%
B_002 $2.72 $7.36 171%
E_001 $0.62 $1.78 187%
R_003 $4.00 $13.20 230%
6 rows selected
You can simplify your query so you only select from the Groceries table once since your My_Output column is only a function of numbers you are already producing the self join is not necessary. Then I've used RANK to get the top records (although if you are not concerned about ties ROWNUM will work better):
SELECT g.Grocery_Item,
g.TOTAL_IN_2000,
g.TOTAL_IN_2025,
g.My_Output
FROM ( SELECT Grocery_Item,
TO_CHAR(TOTAL_IN_2000, '$99,990.00') TOTAL_IN_2000,
TO_CHAR(TOTAL_IN_2025, '$99,990.00') TOTAL_IN_2025,
TO_CHAR(ROUND(((TOTAL_IN_2025 / TOTAL_IN_2000) - 1) * 100), '9,990') || '%' as My_Output,
RANK() OVER(PARTITION BY Grocery_Item ORDER BY (TOTAL_IN_2025 / TOTAL_IN_2000) - 1 DESC) AS GroceryRank
FROM ( SELECT g.Grocery_Item,
SUM(g.Price_IN_2000) TOTAL_IN_2000,
SUM(g.Estimated_Price_In_2025) TOTAL_IN_2025
FROM GROCERY_PRICES g
GROUP BY g.Grocery_Item
) g
) g
WHERE GroceryRank = 1;
I've also simplified your percentage calculation.
Try this instead:
select *
from (Select O.Grocery_Item, TO_CHAR(sum(g.Price_IN_2000), '$99,990.00') TOTAL_IN_2000,
TO_CHAR(sum(g.Estimated_Price_In_2025), '$99,990.00') TOTAL_IN_2025,
TO_CHAR(Round(O.MY_OUTPUT),'9,990') || '%' as My_Output
From GROCERY_PRICES g join
(SELECT GROCERY_ITEM,
(((sum(Estimated_Price_In_2025) -
sum(Price_IN_2000))/sum(Price_IN_2000))*100
) MY_OUTPUT
FROM GROCERY_PRICES
GROUP BY GROCERY_ITEM
) O
on G.GROCERY_ITEM = O.GROCERY_ITEM
GROUP BY O.GROCERY_ITEM, O.MY_OUTPUT
ORDER BY my_output desc
) t
where rownum = 1
The problem is that your subquery only has outer references. So, the o.my_output is coming from the outer table, not the from clause in the subquery. You are comparing a value to itself, which for non-NULL values is always true.
Since you want the maximum value, the easiest way is to order the list and take the first row. You can also do this with analytic functions, but rownum is usually more efficient.
I realize this is a ridiculous request, but what I'm trying to do is pull multiple records back into a single column along with some literal text.
So given a table like this
REGION CITY SID
-------------------
1 Chicago 1234
1 Palatine 567
1 Algonquin 234
1 Wauconda 987
I would like to see back a single record with a column, other columns like region are fine, but a single column like this
<option value="1234">Chicago</option><option value="567">Palatine</option><option value="234">Algonquin</option><option value="987">Wauconda</option>
Any thoughts on how to do this? I'm running Oracle 9i and cannot do this in PL/SQL
Okay the table format has changed a bit, but the idea is the same
COUNTRY STORECODE STORE_NAME
------------------------------
USA 1234 Chicago
USA 567 Palatine
CAN 987 Toronto
So I found this code going through the links listed
SELECT COUNTRY,
LTRIM(MAX(SYS_CONNECT_BY_PATH(STORECODE,','))
KEEP (DENSE_RANK LAST ORDER BY curr),',') AS COUNTRY_HTML
FROM (SELECT COUNTRY,
STORECODE,
ROW_NUMBER() OVER (PARTITION BY COUNTRY ORDER BY STORECODE) AS curr,
ROW_NUMBER() OVER (PARTITION BY COUNTRY ORDER BY STORECODE) -1 AS prev
FROM tablename)
GROUP BY COUNTRY
CONNECT BY prev = PRIOR curr AND COUNTRY = PRIOR COUNTRY
START WITH curr = 1;
And when I run it I see this output
COUNTRY COUNTRY_HTML
--------------------
USA 1234,567
CAN 987
My thought was simply to have the inner select pull from another select where I do my concat of the STORECODE and STORE_NAME along with the html required like this...
SELECT COUNTRY,
LTRIM(MAX(SYS_CONNECT_BY_PATH(RECORD_HTML,','))
KEEP (DENSE_RANK LAST ORDER BY curr),',') AS COUNTRY_HTML
FROM (SELECT COUNTRY,
RECORD_HTML,
ROW_NUMBER() OVER (PARTITION BY COUNTRY ORDER BY RECORD_HTML) AS curr,
ROW_NUMBER() OVER (PARTITION BY COUNTRY ORDER BY RECORD_HTML) -1 AS prev
FROM (SELECT COUNTRY, '<option value="' || STORECODE || '">' || STORE_NAME || '</option>' AS RECORD_HTML FROM tablename))
GROUP BY COUNTRY
CONNECT BY prev = PRIOR curr AND COUNTRY = PRIOR COUNTRY
START WITH curr = 1;
While our front end environment does accept the query when I try to review the results I get a error: the resource is invalid. You may need to re-create of fix the query before viewing.
I know that error probably isn't helpful, but any ideas why my version isn't working?
Thanks!
It's disgusting but you could do something like this:
select replace(blah2,',','')
from ( select wm_concat(blah) as blah2
from ( select '<option value="' || sid || '">' || city || '</option>' as blah
from my_table
)
)
Have you played around with DBMS_XMLGEN?
You can create an aggregate function in Oracle, see documentations.