Problem writing a sql query
I am a Java Developer and new to database.
Database Table:
Table 'Authors' with fields 'Author'(Varchar2), 'Code'(Varchar2), 'Id'(Varchar2 ~ Not a primary key, multiple records can have same value) and 'Date_Sequence'(Number). The possible values for 'Code' could be either 'Yes' or 'No'.
Approach:
I can select a list of authors, say AYES AUTHORS with code 'Yes' and a list of authors, say NOES AUTHORS with code 'No' from my web page.
When I submit the request, I need to retrieve all the Id's, where AYES Authors voted 'Yes' and NOES Authors voted 'No'.
I have come up with the following query:
SELECT DISTINCT ID FROM AUTHORS WHERE AUTHOR IN ('my selected AYES list') AND CODE = 'Yes'
INTERSECT
SELECT DISTINCT ID FROM AUTHORS WHERE AUTHOR IN ('my selected NOES list') AND CODE = 'No'
Problem:
Now the problem here being, I have to retrieve the id's where the 'Date Sequence' is same for 'Yes' and 'No'. Not sure how to link the Date_Sequence for both the queries across the intersect clause. Any clue is highly appreciated.
Thanks.
Not sure if i understand what the logic behind it is, but try this..
WITH AUTHORS AS (SELECT 'AYES1' AUTHOR, 'Yes' CODE, '1' ID, TRUNC(SYSDATE) DATE_SEQ FROM DUAL
UNION ALL
SELECT 'AYES2' AUTHOR, 'Yes' CODE, '2' ID, TRUNC(SYSDATE)-1 DATE_SEQ FROM DUAL
UNION ALL
SELECT 'AYES3' AUTHOR, 'No' CODE, '3' ID, TRUNC(SYSDATE) DATE_SEQ FROM DUAL
UNION ALL
SELECT 'NOES1' AUTHOR, 'No' CODE, '1' ID, TRUNC(SYSDATE) DATE_SEQ FROM DUAL
UNION ALL
SELECT 'NOES2' AUTHOR, 'No' CODE, '2' ID, TRUNC(SYSDATE) DATE_SEQ FROM DUAL
SELECT AYES.ID, AYES.DATE_SEQ
FROM AUTHORS AYES,
AUTHORS NOES
WHERE AYES.AUTHOR IN ('AYES1', 'AYES2', 'AYES3') AND AYES.CODE='Yes'
AND NOES.AUTHOR IN ('NOES1', 'NOES2', 'NOES3') AND NOES.CODE='No'
AND AYES.ID=NOES.ID
AND AYES.DATE_SEQ=NOES.DATE_SEQ
ID DATE_SEQ
1 22.10.08
SQL>
Similar Messages
-
Problem writing a sql query for a select list based on a static LOV
Hi,
I have the following table...
VALIDATIONS
ID Number (PK)
APP_ID Number
REQUESTED Date
APPROVED Date
VALID_TIL Date
DEPT_ID Number (FK)
I have a search form with the following field item variables...
P11_DEPT_ID (select list based on dynamic LOV from depts table)
P11_VALID (select list based on static Yes/No LOV)
A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
SELECT v.APP_ID,
v.REQUESTED,
v.APPROVED,
v.VALID_TIL,
d.DEPT
FROM DEPTS d, VALIDATIONS v
WHERE d.DEPT_ID = v.DEPT_ID(+)
AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
Can anyone help me to extend my query to include this situation?
Thanks.Hello !
Let's have a look at my example:create table test
id number
,valid_til date
insert into test values( 1, sysdate-3 );
insert into test values( 2, sysdate-2 );
insert into test values( 3, sysdate-1 );
insert into test values( 4, sysdate );
insert into test values( 5, sysdate+1 );
insert into test values( 6, sysdate+2 );
commit;
select * from test;
def til=yes
select *
from test
where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
=decode('&til','yes',1,-1);
def til=no
select *
from test
where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
=decode('&til','yes',1,-1);
drop table test; It's working fine, I've tested it.
The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
For understandings:
1.) TRUNC removes the time part of DATE
2.) The difference of to date-values is the number of days between.
3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
4.) DECODE is like an IF.
Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
Good luck,
Heinz -
Mapping Problem with Native SQL query
My application uses a native SQL query to locate certain entities. It looks like this:
SELECT UPLOADATTEMPTREF, STUDENTNUMBER, USERID, WORKITEMCODE, WORKITEMINSTURN, WORKITEMTITLE, MODULERUNCODE, STUDENTNAME, SUBMISSIONDEADLINE, UPLOADATTEMPTSERVERDATE, FILENAME, UPLOADCOMPLETESERVERDATE, NEWFILENAME, FILESIZE, FILEPATH, DOWNLOADSERVERDATE, MODULECODE, MODULETITLE
FROM Submission_Attempt WHERE UPLOADATTEMPTREF IN (
SELECT uploadAttemptRef FROM (" +<br /><br /> "SELECT MAX(uploadAttemptRef) AS uploadAttemptRef, UserID, workItemInstUrn, " +<br /><br /> "workItemCode FROM Submission_Attempt where workiteminsturn = ?1 " +<br /><br /> "GROUP BY UserID, workItemInstUrn, workItemCode) Table1 ) " +<br /><br /> "and uploadCompleteServerDate is not null;"<br />
My expectation was that EclipseLink would be able to handle the mapping of the results to the entity quite happily. However, I get a NonSynchronizedVector of Objects - each Object representing one field of data.
I need help with either:
Converting the above SQL into JPQL so that I (hopefully) don't have to worry about the SQL or
Understanding why this isn't working properly...
Anyone able to help?
Edited by: phunnimonkey on Nov 6, 2008 3:33 AMNever mind - the problem was to do with not specifying a class when creating the native query.
-
Problem executing a sql query in 10g environment
Hi,
I am having problem executing the following sql query in 10g environment. It works fine in 8i environment.
I tried to_number(to_char) and it did not work.
**A.APPL_ACTION_DT >= TO_CHAR("&v_strBeginStatusDate&", 'DD-MON-YYYY') AND A.APPL_ACTION_DT <= TO_CHAR("&v_strEndStatusDate&", 'DD-MON-YYYY')))**
Any suggestions..
--PavanI would be surprised if that worked in 8i as posted, although I no longer have 8i to test. You do not tell us the error message you are getting, but there are several things wrong with what you posted.
First, the substitution variable requires only the & at the beginning, you have one on each end of your string, the one at the end will remain in the string that is passed to the database.
Second, you cannot TO_CHAR a string with a date format as you are trying to do. The TO_CHAR function is overloaded and has two basic forms TO_CHAR(date, format_model) and TO_CHAR(number, format_model). Note that neither takes a string. It would appear that at least current versions of Oracle choose the second signature unless specifically passed a date datatype.
SQL> select to_char('&h', 'dd-mon-yyyy') from dual;
Enter value for h: 12
old 1: select to_char('&h', 'dd-mon-yyyy') from dual
new 1: select to_char('12', 'dd-mon-yyyy') from dual
select to_char('12', 'dd-mon-yyyy') from dual
ERROR at line 1:
ORA-01481: invalid number format modelalthough I suspect that the error you are getting with your posted code is more likely to be ORA-01722: invalid number.
Depending on the data type of appl_action_date, you are probably lokoing for TO_DATE instead of TO_CHAR.
John -
Hello All,
I have one problem regarding sql query.
I have one internal table which contains equnr and bis as fields. There are two database tables egerr and eastl. The structure for tables are as follows:
Fields for egerr:
equnr, bis, logiknr in which first two fields form key.
Field for eastl:
anlage, bis, logiknr in which all fields form primary key.
I want to select records from internal table which does not have record in eastl.
For the reference we can extract logiknr from egerr by using intarnal table and then use this logiknr to check entry in table eastl. but i want those equnr which are in internal table but not mapped in eastl.
I want the most efficient solution for this as there are many records.
Thanks..... and if you have any queries then let me know.
Jignesh.hi,
as per ur statement, u want the field equnr which exists in the internal table but not in eastl. now for comparing with eastl u will need to check for all the three fields as they form the key...
get data from egerr for matching equnr and bis in your internal table
i.e. assuming ur table is itab and itab_logiknr contains a single field logiknr
select logiknr from egerr
into table itab_logiknr
for all entries in itab
where equnr eq itab-equnr
and bis eq itab-bis.
now from this data (itab_egerr), compare the data with that in eastl for matching (or non matching) values of logiknr
assuming data from eastl lies in itab_eastl
select anlage bis logiknr from eastl into itab_eastl
for all entries in itab_logiknr
where logiknr eq itab_logiknr-logiknr.
for non matching entries u can select data from eastl which is not present in itab_eastl now....
(but mind you....since all fields of eastl form the key, u might not be getting the correct data) so if possible study ur scenario again and see if u can search the eastl table comparing all fields in the primary key)
try this....get back in case of any clarifications
hope it gives u some pointers...
regards,
PJ -
Problem creating an sql query with a parameter which is a list
Hi,
Im having a problem creating a certain SQL query.
The query looks like this:
SELECT gstock_id FROM germplasm_stock gps, germplasm gp WHERE gps.germplasm_id = gp.germplasm_id AND organism_id IN ($childList:VARCHAR).
the organism_id field is of DECIMAL type.
the parameter childList is actually a list of Id's, something like: 123,124,789
and it is created dynamically by an other function, so I cant just put it there staticlly.
I tried using the ARRAY type instead of VARCHAR, but that didn't work,
anyone knows how can I give this query a parameter which is a list of numbers ?
ThanksI have tried all the following options and the same issue occurs:
EXEC dbo.uspGetSiteChanges @ChangeVersion = ?
With Parameter: 0, @ChangeVersion, ChangeVersion
EXEC dbo.uspGetSiteChanges ?
With Parameter: 0, @ChangeVersion, ChangeVersion
In my first data flow I use the following and it works on two OLE DB Sources:
EXEC dbo.uspGetSiteChanges @ChangeVersion = ?
With:
In my second data flow task, I use the same command and parameter mappings and it fails, very strange. -
Problem in executeQuery(SQL query sentence with a ' );
for example:
String strName="";
//here strName is searching key value.
String strQueryString="SELECT * FROM Authors WHERE name='" strName "'";
ResultSet rs=st.executeQuery(strQueryString);
if strName value is "yijun_lee",that will return all information which the name columns value is "yijun_lee" with SQL Query sentence SELECT * FROM Authors WHERE name='yijun_lee'
but if strName value is "yijun ' lee",that value contains a '.that will error!
how to do?
thanks very much!You could parse <strName > and insert another ' for each '
A concrete example would be SELECT * FROM Authors WHERE name='yijun '' lee'HTH -
Problem with a SQL query involving dates
I have a database with each task made by a developer in the company's systems, with 2 fields to determine the duration of the tasks: begin_date and end_date, both Dates. Now I have to make an SQL query returning the total of hours each one worked counting every task, so I'm using something like this (simplifying):
select user_id, sum(end_date - begin_date)
from task
group by user_id
but I get a weird fractional number. How do I do this query?What database are you using? Oracle?
The weird fractional number is probably the difference between the dates in days. If you want it in hours, try multiplying it with 24.
select user_id, sum(end_date - begin_date) * 24
from task
group by user_id -
Help needed on writing a SQL query
Here is my table that shows records of 3 ORDER_ID (10, 20 and 30). All I need to do is, pick the first record of each order_id and check the event_id, if the event_id is same for the next record, ignore it, else show it and ignore rest all records for that order_id. This way my query output will show only two records for each ORDER_ID. Query should produce records that are in BOLD in the sample data. (Database - 11g)
Thanks for your help in advance
ORDER_ID EVENT_ID EVNT_DATE STATE_CODE
*10 16937555 20100212 COMPLETE*
10 16937555 20100212 ACTIVE
*10 16308004 20100129 OCCURRED*
10 16131904 20100125 ACTIVE
10 16270684 20100128 OCCURRED
10 14899116 20091213 ACTIVE
10 16085672 20100123 COMPLETE
10 16085673 20100123 OCCURRED
10 14899119 20100123 COMPLETE
10 14899120 20100123 COMPLETE
*20 17134164 20100223 COMPLETE*
20 17134164 20100223 ACTIVE
20 17134164 20100223 STARTED
*20 15479131 20100105 OCCURRED*
20 15478409 20100105 OCCURRED
20 15478408 20100105 ACTIVE
20 15119404 20100105 COMPLETE
20 14346123 20091129 ACTIVE
20 15467821 20100104 OCCURRED
20 14346125 20091216 COMPLETE
20 14346126 20091215 COMPLETE
20 14346126 20091214 COMPLETE
*30 18814670 20100412 COMPLETE*
30 18814670 20100412 ACTIVE
*30 18029509 20100320 OCCURRED*
30 16853720 20100211 ACTIVE
30 17965764 20100319 OCCURRED
30 16386708 20100211 COMPLETE
30 16804451 20100211 OCCURRED
30 15977897 20100121 ACTIVE
Edited by: sarvan on Aug 12, 2011 7:16 AMtry this [Not fully tested]
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
Elapsed: 00:00:00.00
SQL> SELECT *
2 FROM (SELECT order_id, event_id, evnt_date, state_code, next_evntid,
3 ROW_NUMBER () OVER (PARTITION BY event_id ORDER BY NULL)
4 AS rownm
5 FROM (WITH t AS
6 (SELECT 10 AS order_id, 16937555 AS event_id,
7 20100212 AS evnt_date, 'COMPLETE' AS state_code
8 FROM DUAL
9 UNION ALL
10 SELECT 10, 16937555, 20100212, 'ACTIVE'
11 FROM DUAL
12 UNION ALL
13 SELECT 10, 16308004, 20100129, 'OCCURRED'
14 FROM DUAL
15 UNION ALL
16 SELECT 10, 16131904, 20100125, 'ACTIVE'
17 FROM DUAL
18 UNION ALL
19 SELECT 10, 16270684, 20100128, 'OCCURRED'
20 FROM DUAL
21 UNION ALL
22 SELECT 20, 17134164, 20100223, 'COMPLETE'
23 FROM DUAL
24 UNION ALL
25 SELECT 20, 17134164, 20100223, 'ACTIVE'
26 FROM DUAL
27 UNION ALL
28 SELECT 20, 17134164, 20100223, 'STARTED'
29 FROM DUAL
30 UNION ALL
31 SELECT 20, 15479131, 20100105, 'OCCURRED'
32 FROM DUAL) -- End of test data
33 SELECT order_id, event_id, evnt_date, state_code,
34 LEAD (event_id, 1, 0) OVER (PARTITION BY order_id ORDER BY NULL)
35 AS next_evntid
36 FROM t)
37 WHERE event_id = next_evntid)
38 WHERE rownm <= 2
39 /
ORDER_ID EVENT_ID EVNT_DATE STATE_CO NEXT_EVNTID ROWNM
10 16937555 20100212 COMPLETE 16937555 1
20 17134164 20100223 COMPLETE 17134164 1
20 17134164 20100223 ACTIVE 17134164 2
Elapsed: 00:00:00.00
SQL> PS - You should seriously think about ordering the data before you do this kind off operations.
Edited by: Sri on Aug 12, 2011 9:12 AM -
Problem Writing java.sql.Date to MS Access
I have a relatively simple application that is for my own use (not distributed on an enterprise-wide basis). As I don't have an IT staff, I'm using a rudimentary Java front-end (v1.3.1) and a Microsoft Access backend.
I seem to have trouble using INSERT/UPDATE statements with the MS Access Date/Time data type. Below is an example of code being used (id is defined as Text, amount is a Number and timestamp is Date/Time):
conn = DriverManager.getConnection("jdbc:odbc:markets", "", "");
conn.setAutoCommit(true);
String sql = "INSERT INTO temp (id, amount, timestamp) VALUES (?, ?, ?)";
PreparedStatement stmt = conn.prepareStatement(sql);
String id = args[0];
int len = id.length();
java.sql.Date dt = new java.sql.Date(new java.util.Date().getTime());
stmt.setString(1, id);
stmt.setDouble(2, id.length());
// I think the problem is here - the JDBC driver doesn't properly map dates to Access???
stmt.setDate(3, dt);
stmt.execute();
stmt.close();
conn.close();And I get the following error:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access
Driver] Syntax error in INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException (JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError (JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect (JdbcOdbc.java:3065)
at sun.jdbc.odbc.JdbcOdbcStatement.execute (JdbcOdbcStatement.java:338)
at TestWritingDate.main(TestWritingDate.java:31) I'm virtually certain this is a translation problem with
the java.sql.Date and the JDBC driver. But I can't seem
to overcome this. Any help is DESPERATELY needed.
Thanks.
MattThat was it....thanks...didn't even consider that....perhaps I should start using class names that are already in use too :-). Thanks again...
-
Hello ,
I am using oracle 10g apex 3.2.
I have assosiated 2 schema "vpmys and vp" with one workspace.
In the application , i created a new page of report ,which is assosiated with one schema called "vp" and i wish to run this query
select * from vpmys.t_devotees
minus
select * from vp.t_devotees
Same database dmp is installed in both schema except that the no of rows may be more or less in one database.So first i need to know the added rows and what are they and then insert the same no of rows into another db.
But this doesnt run in the application.
But it runs in the SQL Command window.
So what way i should change the query so that it runs.
Thanks
SwapnaPost your question in Application Express Forum
Oracle Application Express (APEX) -
Hey all,
I made a view so that I could join three databases together and put the results on the association table. However, I keep getting an error that I'm not using the SELECT keyword, when I am. Maybe there is another bug somewhere else?
CREATE OR REPLACE VIEW "SUPPLIER_COMPETENCY_VW" ("SUPPLIER_PK", "COMPETENCY_PK", "ROW_CREATE_EMAIL", "ROW_CREATE_TIMESTAMP", "ROW_UPDATE_EMAIL", "ROW_UPDATE_TIMESTAMP") AS
SELECT
SUPPLIER_COMPETENCY_VW.SUPPLIER_PK||'|'||SUPPLIER_COMPETENCY_VW.COMPETENCY_PK,
SUPPLIER_COMPETENCY_VW.SUPPLIER_PK,
SUPPLIER_COMPETENCY_VW.COMPETENCY_PK,
SUPPLIER_COMPETENCY_VW.ROW_CREATE_EMAIL,
SUPPLIER_COMPETENCY_VW.ROW_CREATE_TIMESTAMP,
SUPPLIER_COMPETENCY_VW.ROW_UPDATE_EMAIL,
SUPPLIER_COMPETENCY_VW.ROW_UPDATE_TIMESTAMP
FROM
SUPPLIER_COMPETENCY_TB, TPL_SUPPLIERS_TB, TPL_CONTACTS_TB
WHERE
TBL_SUPPLIER_TB.SUPPLIER_PK = SUPPLIER_COMPETENCY_TB.SUPPLIER_PK
AND
TBL_COMPETENCY_TB.COMPETENCY_PK = SUPPLIER_COMPETENCY_TB.SUPPLIER_PK
Any Suggestions?
SumerCREATE VIEW "SUPPLIER_COMPETENCY_VW" ("SUPPLIER_PK", "COMPETENCY_PK", "ROW_CREATE_EMAIL", "ROW_CREATE_TIMESTAMP", "ROW_UPDATE_EMAIL", "ROW_UPDATE_TIMESTAMP") AS
SELECT
SUPPLIER_COMPETENCY_TB.SUPPLIER_PK||'|'||SUPPLIER_COMPETENCY_TB.COMPETENCY_PK,
SUPPLIER_COMPETENCY_TB.SUPPLIER_PK,
SUPPLIER_COMPETENCY_TB.COMPETENCY_PK,
SUPPLIER_COMPETENCY_TB.ROW_CREATE_EMAIL,
SUPPLIER_COMPETENCY_TB.ROW_CREATE_TIMESTAMP,
SUPPLIER_COMPETENCY_TB.ROW_UPDATE_EMAIL,
SUPPLIER_COMPETENCY_TB.ROW_UPDATE_TIMESTAMP
FROM
SUPPLIER_COMPETENCY_TB
The same error keeps coming up of being unable to find the SELECT keyword, yet im not sure where the error is.
Sumer -
SQL query problem - select max (case... aggregate function)
Hi,
I have a problem with below sql query, it gives me problem/error message 'ORA-00937: not a single-group group function', why?
select sag.afdeling, sag.sagsnr, to_char(sag.start_dato, 'yyyy-mm-dd'), sag.stat, BOGF_TRANS.TRANSTYPE,
max (case when BOGF_TRANS.TRANSTYPE = 'K' then sum(bogf_trans.belobdkk) end) + -- as "TRANSTYPE K",
max (case when BOGF_TRANS.TRANSTYPE = 'D' then sum(bogf_trans.belobdkk) end) as "TRANSTYPE K & D",
max (case when BOGF_TRANS.TRANSTYPE = 'S' then sum(bogf_trans.belobdkk) end) as "SUM TRANSTYPE S"
from sag
join bogf_trans on sag.selskab = bogf_trans.selskab and sag.sagsnr = bogf_trans.sagsnr and sag.afdeling = bogf_trans.afdeling
where SAG.SELSKAB=37 and SAG.AFDELING = 'SUS' AND SAG.SAGSNR = 10876
group by sag.afdeling, sag.sagsnr, sag.start_dato, sag.stat, BOGF_TRANS.TRANSTYPE
If I exclude (columns) as below it give me correct summations (max (case... sum(...)) but then I miss some important info that I need
select
max (case when BOGF_TRANS.TRANSTYPE = 'K' then sum(bogf_trans.belobdkk) end) + -- as "TRANSTYPE K",
max (case when BOGF_TRANS.TRANSTYPE = 'D' then sum(bogf_trans.belobdkk) end) as "TRANSTYPE K & D",
max (case when BOGF_TRANS.TRANSTYPE = 'S' then sum(bogf_trans.belobdkk) end) as "SUM TRANSTYPE S"
from sag
join bogf_trans on sag.selskab = bogf_trans.selskab and sag.sagsnr = bogf_trans.sagsnr and sag.afdeling = bogf_trans.afdeling
where SAG.SELSKAB=37 and SAG.AFDELING = 'SUS' AND SAG.SAGSNR = 10876
group by sag.afdeling, sag.sagsnr, sag.start_dato, sag.stat, BOGF_TRANS.TRANSTYPE
Any ideas?Moved to more sutable forum, sorry.
-
Strange problem with SQL query in toad.
Guys,
My colleague is up with a strange problem with an SQL query that if it is run in toad encounters the "ORA-03113: end-of-file on communication channel" problem,but if run in SQL plus executes just fine.
Do anyone have thoughts about this strange error in toad?
Thanks!!!!
Regards,
BhagatNot sure what version of TOAD you have but it may have shipped with SQLMonitor which montiors SQL sent from Windows apps . Navigation should be similar to;
Start~Programs~Quest Software~TOAD for Oracle~Tools~SQLMonitor
or
C:\Program Files\Quest Software\Toad for Oracle\SQLMonitor.exe
To use it, start TOAD and connect, start SQLMonitor and click the checkbox for TOAD.exe, then execute the query. SQLMonitor will show you the actual query that TOAD sent to the client. It may be exactly what you sent or it may contain some extras. -
Help needed in building a sql query
Hello,
I am using Oracle 10g db.
I have 3 tables table1 and table2 and table3
I am writing one sql query which is like
select table1.a a1,(select distinct b from table2,table3 where table2.id=table3.id and table1.id=table2.id) b1
from table1
Now the b1 value may give more then 1 values so when i am trying to execute the query its giving me error.
What i would like to have is if it gives returns more then 1 value then add that value as a new column means if b1 gives like abc and def as values.
Then i want the sql to return like
acolvalue abc def as a single row.
Is this possible to do?
ThanksHello,
The approach which i took is i wrote a function which gives me the b values , sseparated.
Then i am building a outer query considering the max of b so i just found there are max 10 values which one row is showing.
select b11,b12,b13,,,b10
from (
select table1.a a1,func(select distinct b from table2,table3 where table2.id=table3.id and table1.id=table2.id) b1
from table1)
but now i am facing problem like the value of b1 is a,b,c
i want to use the substr and instr function to get
a as b11
b as b12
c as b13
can anyone pls help me out to write a query? i am getting b11 but other values are somehow not coming.
for b11
i used
substr(b1,1,instr(b1,',',1,1)-1)
Thanks
Maybe you are looking for
-
Using h:outputlink with rendered attribute
Hey, I wanna know how to use the rendered tag with h:outputlink. I have a variable called requestNumber in the request entity bean. Now, I dont want the link to show up when the requestNumber is =="To be set". How can this be done? This is the code i
-
I ordered a new iPod Touch, since my 4th Generation Touch is completely broken. This is the first time I've ordered an item from the Apple Store. I coughed up an extra 10 bucks to get the 2-3 day shipping--I got my name engraved into it, so that sets
-
Nvidia 8600 - is there a risk of buying MPB 2.4?
I have a good offer to buy used MPB 2.4 (MacBookPro 3,1) produced at week 23 of 2007. I know it has potentially risky GPU chip 8600. A friend of mine who was using this machine less than two years never run games, he never yet experienced death scree
-
Help with Acrobat X crash when trying to distribute
Whenever I get to the point to distribute my new form, no matter if I choose to automatically to send via email or save a local copy and attach later. Acrobat instantly crashes with Event ID 1000 stating: Faulting application name: Acrobat.exe, ve
-
I went to uninstall Photoshop CC today and the alias on my Mac says that the uninstaller it was pointing to cannot be found. I just upgraded to Yosemite maybe that has something to do with it. I've read that I can install CC and then the uninstaller