Find a string between numeric in a column using SQL Query
Hi need help with the query in SQL. let say i have a column that has 2000 data.. i just need to show the data that has A at the strating of the data. For example:
A100001
W23456
A234444
I just need to show all the data got "A" at the start.
Thank u
I don't think there is any standard command, so you will need to search for the pattern matching commands of your DBMS.
In SQL Server the keyword is "like", so your query would be Select col1 from tbl1 where col1 like 'A%'
Try to take over the world!
Similar Messages
-
Need to find the assets associated to a BCC project using SQL query
Hi,
Given a BCC project (project_id), I need to find the assets (type of asset, version, status etc) in that project using SQL queries.
I need this for reporting purpose and cannot do this programatically using any code.
Surprisingly ATG does not store this association in a direct way. Can someone provide me the query if you have already done this before?
I tried enabling loggingDebug in PublishingRepository and VersionManagerRepository to get the queries, but I did not get what I want.
Thanks in advance,
Gopinath RamasamyUPDATE:
When a project is selected in BCC, ATG is doing something crazy, as it appears to me, of querying all the tables (ofcourse when there is a cache miss) in all the versioned item descriptor with the workspace id of the project to display the assets contained in it.
I do not see an easy or direct way of coming up with a query for this requirement.
Please let me know if anyone has any other idea.
Thanks,
Gopinath Ramasamy -
How to pass a string value from XL sheet cell to SQL query.
Hi,
I am using SQL query in XL sheet to fetch some data. for that i am using ODBC connection. Now I want to pass a string from XL sheet Cell value in the where clause of Select statement, Please let me know how to do this.
Below is My code:
nge("A4").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DRIVER={Microsoft ODBC for Oracle};UID=xyz;PWD=xyz;SERVER=xyz;" _
, Destination:=Range("A4"))
.CommandText = Array( _
"SELECT CRYSTAL_REPORT1.PROJECT, CRYSTAL_REPORT1.OBJECT" & Chr(13) & "" & Chr(10) & "FROM NAIODEV.CRYSTAL_REPORT1 CRYSTAL_REPORT1" _
.Name = "Query from gg"
Thanks,
PriyaWhat does "XL" (whatever that is) have to do with Crystal Reports which is what you are obviously working with have to do with the Oracle database?
The rules for using Crystal with Oracle are quite clearly described in all the Crystal Reports docs ... you MUST use IN OUT ref cursors unless you are doing direct table or view access. -
How to show the VALUE as the Column Header using SQL query?
Hi
I have a requirement to show the picked value as the column header using SQL query.
Example:
======
SELECT EMPNO FROM EMP
WHERE EMPNO=7934;
Result Should be:
7934
7934I have a requirement to show the picked value as the column header using SQL query.In sql*plus you can do
SQL> set verify on
SQL> def e = 7934
old: SELECT empno "&&e" FROM emp WHERE empno = &&e
new: SELECT empno "7934" FROM emp WHERE empno = 7934
SQL> SELECT empno "7934" FROM emp WHERE empno = 7934
7934
7934
1 row selected. -
Difference between values in 2 rows in SQL query
I have to find the difference between inventory onhand in the same store in week1 and week2.
I tried to do it in one "select" query something like :
SELECT store_id, ( suppose to be function that calculates difference) FROM my_table WHERE week=week1 or week=week2 GROUP BY store_id
however I have no idea how to find the difference between the valuues in two separate rows.
thanks in advance.If you have only two weeks in your data. This can work.
SQL> select * from emp
2 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7839 KING PRESIDENT 17-NOV-81 5000 10
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7900 JAMES CLERK 7698 03-DEC-81 950 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7369 SMITH CLERK 7902 17-DEC-80 800 20
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
8888 KING PRESIDENT 17-NOV-81 7000 10
9999 ADAMS CLERK 7788 12-JAN-83 7000 20
16 rows selected.
SQL> select ename, max(sal) - min(sal) diff
2 from emp
3 group by ename
4 /
ENAME DIFF
ADAMS 5900
ALLEN 0
BLAKE 0
CLARK 0
FORD 0
JAMES 0
JONES 0
KING 2000
MARTIN 0
MILLER 0
SCOTT 0
SMITH 0
TURNER 0
WARD 0
14 rows selected.
SQL> Cheers
Sarma. -
Hi,
how to find using SCCM SQL query, application deployed on win 7 machines with SCCM 2012 server or user/technician installed manually. Please let me know.Thanks, is it not possible via any script also?
Like Torsten said, how can you tell the difference between CM12 installed applications and locally installed? Once you can answer that, then you can write report.
Garth Jones | My blogs: Enhansoft and
Old Blog site | Twitter:
@GarthMJ -
Need Help in Splitting a String Using SQL QUERY
Hi,
I need help in splitting a string using a SQL Query:
String IS:
AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
Sample Output should look like:
SNO STRING
1 AFTER PAINT
2 ACOUSTICAL
3 1
4
5 9" MEMBRAIN
{code}
FYI i am using Oracle 9.2There's this as well:
with x as ( --generating sample data:
select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
select str,
row_number() over (partition by str order by rownum) s_no,
cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
from x,
table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
STR S_NO RES
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 1 AFTER PAINT
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 2 ACOUSTICAL
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 3 1
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 4
AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN 5 9" MEMBRAIN
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 1 BEFORE PAINT
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 2 ELECTRIC
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 3 2
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 4
BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN 5 45 caliber MEMBRAIN
{code} -
Converting rows to columns using dynamic query.
I am trying to use the below code that I founnd on the web to conver rows to columns. the reason that I want to use dynamic query is that the number of rows are not know and changes.
declare
lv_sql varchar2(32767) := null ;
begin
lv_sql := 'SELECT Iplineno ';
for lv_rec in (SELECT distinct vendor from bidtabs where letting = '10021200' and call ='021')
loop
lv_sql := lv_sql
|| CHR(10)
|| ', MAX( DECODE( vendor, '
|| chr(39)
|| lv_rec.vendor
|| CHR(39)
|| ', bidprice, NULL ) ) as "'
|| lv_rec.vendor
|| '" ' ;
end loop;
lv_sql := lv_sql
|| CHR(10)
|| 'FROM bidtabs where letting = ''10021200'' and call = ''021'' and lineflag = ''L'' '
|| CHR(10)
|| 'GROUP BY iplineno ;' ;
here is the result
BIDPRICE CALL IPLINENO LETTING VENDOR
9,585 021 0010 10021200 C0104
1,000 021 0020 10021200 C0104
1,000 021 0030 10021200 C0104
17 021 0040 10021200 C0104
5 021 0050 10021200 C0104
11,420 021 0010 10021200 K0054
1,100 021 0020 10021200 K0054
1,100 021 0030 10021200 K0054
5 021 0040 10021200 K0054
3 021 0050 10021200 K0054
8,010 021 0010 10021200 V070
900 021 0020 10021200 V070
1,320 021 0030 10021200 V070
11 021 0040 10021200 V070
3 021 0050 10021200 V070
and here is the desired output
CALL IPLINENO LETTING C0104 K0054 V070
021 0010 10021200 9,585 11,420 8,010
021 0020 10021200 1,000 1,100 900
021 0030 10021200 1,000 1,100 1,320
021 0040 10021200 17 5 11
021 0050 10021200 5 3 3Here is the error message I am getting:
RA-06550: line 22, column 43:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << close current delete fetch lock insert
open rollback savepoint set sql execute commit forall merge
pipe -
Changing Column Value Style using SQL Query
Hi,
I'm trying to build a fantasy basketball game with APEX. I have a table that has a list of games. I need to change the color of the column value i.e. the name of the team that wins according to a SQL query Here's an example:
TABLE NAME: LATESTGAMES
Home Away Homepoints Awaypoints
Boston Cleveland 105 101
Toronto Washington 122 83
What I want to do is display the winning team i.e. Boston and Toronto in Green since that's the team that won.
The SQL query is:
SELECT HOME,
AWAY,
HOMEPOINTS,
AWAYPOINTS
from LATESTGAMES;
What do I need to do in order to display the Winning Team as Green on every column? Please HelpHello Devilfish,
I did something like that in my DG Tournament application (http://www.dgtournament.com)
Your SQL query can look like this:
SELECT CASE
WHEN (homepoints > awaypoints)
THEN '<span style="color:green;">' || home || '</span>'
ELSE home
END AS home,
SELECT CASE
WHEN (awaypoints > homepoints)
THEN '<span style="color:green;">' || away|| '</span>'
ELSE away
END AS away,
HOMEPOINTS,
AWAYPOINTS
from LATESTGAMES;Hope that gives you an idea,
Dimitri
-- http://dgielis.blogspot.com
-- http://apex-evangelists.com -
Hi, EveryOne,
I tried to insert(update) a string data type using Fixed SQL Query as, for a example:
insert into Masters(MasterName) values([Param.1])
In html form I enter a value in field and press button to call the function. But if enter in the field a String value - nothing inserted in table but if I enter Number - everything works fine. I tried to use commas but the effect is the same.
Thnks,
SerjHello Sergey,
Ryan's sql statement is right. The ' sign is used to mark the [Param.1] as a string.
The sql statement (connection) is language independent, but you have to make sure that you mark up strings and timestamps in the correct way.
In your first statement
Masters(MasterName) values([Param.1])
xMII will replace [Param.1] with the value you type in("yourvalue"). For strings("yourvalue") it will look like this
Masters(MasterName) values(yourvalue)
this should bring back a sql error. You can try it in another sql client.
Hope this help as an explanation.
Regards,
Martin -
Urgent= How to Group selected columns in sql query
Hi,
I need some urgent help on the following sql query. I 'm sure there is an easy way to do this but I'm stacked!Any help will be much appreciated!!
I have a query to retrieve the following columns:
I want the first 9 columns to be grouped together (not to be repeated) for any occurence of the last 3 columns (abs.ABSENCE_START_DATE,abs.ABSENCE_END_DATE, abs.DAYS_TAKEN DAYS_TAKEN_analysis)
SELECT DISTINCT
sum.employee_number ,
sum.EMPLOYEE_NAME,
sum.EMAIL_ADDRESS,
sum.ORGANIZATION ,
sum.BCEBF ,
sum.ALDE ,
sum.CURYRREMDAYS ,
sum.DAYS_TAKEN ,
sum.REMBCE ,
abs.ABSENCE_START_DATE
abs.ABSENCE_END_DATE,
abs.DAYS_TAKEN DAYS_TAKEN_analysis
--TO_CHAR(TO_CHAR(abs.ABSENCE_START_DATE)||' '||TO_CHAR(abs.ABSENCE_END_DATE)||' '||TO_CHAR(abs.DAYS_TAKEN)) DAYS_TAKEN_ANAL
FROM
HB_V_ANNUAL_LEAVE_SUMMARY_REP SUM,
HB_V_AN_LEAV_DAYS_TAKEN_REP ABS
WHERE
sum.employee_number = abs.EMPLOYEE_NUMBER
ORDER BY
sum.employee_number ,
sum.EMPLOYEE_NAME,
sum.EMAIL_ADDRESS,
sum.ORGANIZATION ,
sum.BCEBF ,
sum.ALDE ,
sum.CURYRREMDAYS ,
sum.DAYS_TAKEN ,
sum.REMBCE
Any feedback/help on how to do this will be highly appreciated.
Thanks a lot
ElenaPlease help!!
I used the break command to group columns that I do not want to repeat in my query output. When I run the query without formatting is working. But when I put all formatting to produce the required output I dont get the result I want.
Below is the exact sql query I use:
<<
SET TERMOUT OFF
SET ECHO OFF
SET ARRAY 35
SET HEA OFF
SET FEEDBACK OFF
SET PAGES 2000
col beginLINE format A100
col winsecidLINE format A100
col placeLINE format A100
COL LINEempty1 format A100
COL LINEempty2 format A100
COL LINEempty3 format A100
COL LINEempty4 format A100
COL LINEempty5 format A100
COL LINEempty6 format A100
COL LINEempty7 format A100
COL LINEempty8 format A100
COL LINEempty9 format A100
COL LINEempty10 format A100
col LINECOLempty format A100
col receiverLINE FORMAT A100
COL EMP_EMAIL_ADDRESS FORMAT A100
COL LINEHEADER FORMAT A100
COL unitsLINE FORMAT A100
COL lmLINE FORMAT A100
COL INTITLE FORMAT A100
COL LINECOL1 FORMAT A100
COL CIF FORMAT A100
COL EMPLOYEE_NAME FORMAT A100
COL ORGANIZATION FORMAT A100
COL LINECOL2 FORMAT A100
COL ALHEADER FORMAT A100
col LINECOL3 FORMAT A100
col BCEBF FORMAT A100
col ALDE FORMAT A100
COL CURYRREMDAYS FORMAT A100
COL DAYS_TAKEN FORMAT A100
col LINECOL4 FORMAT A100
COL REMBCE FORMAT A100
col LINECOL5 FORMAT A100
col LINECOL6 FORMAT A100
col ALHEADER2 FORMAT A100
col LINECOL7 FORMAT A100
col endLINE FORMAT A100
break on beginLINE on winsecidLINE on placeLINE on LINEempty1 ON LINEempty2 ON LINEempty3 ON LINEempty4 ON LINEempty5 ON LINEempty6 ON LINEempty7 ON LINEempty8 ON LINEempty9 ON LINEempty10 on receiverLINE on EMP_EMAIL_ADDRESS on LINEHEADER on unitsLINE on lmLINE on INTITLE on LINECOL1 on CIF on EMPLOYEE_NAME on ORGANIZATION on LINECOL2 on ALHEADER on LINECOL3 on BCEBF on ALDE on CURYRREMDAYS on DAYS_TAKEN on LINECOL4 on REMBCE on LINECOL5 on LINECOL6 on ALHEADER2 on LINECOL7 ON LINEempty11 ON endREPORT on endLINE
SPOOL C:\FORMATout.txt
SELECT
'{{begin}} '||chr(10) beginLINE,
'{{winsecid 999999}} '||chr(10) winsecidLINE,
'{{place rbsemail.tif 0 0}} '||chr(10) placeLINE,
' '||chr(10) LINEempty1,
' '||chr(10) LINEempty2,
' '||chr(10) LINEempty3,
' '||chr(10) LINEempty4,
' '||chr(10) LINEempty5,
' '||chr(10) LINEempty6,
' '||chr(10) LINEempty7,
' '||chr(10) LINEempty8,
' '||chr(10) LINEempty9,
' '||chr(10) LINEempty10,
'{{from [email protected]}} '||chr(10) receiverLINE,
'{{fax '|| EMAIL_ADDRESS||' }} '||chr(10) EMP_EMAIL_ADDRESS,
'{{Subject Annual Leave Summary Report as at '||sysdate||' }} '||chr(10) LINEHEADER,
'{{units cm}} '||chr(10) unitsLINE,
'{{lm 2.0}} '||chr(10) lmLINE,
'ANNUAL LEAVE SUMMARY REPORT AS AT '||sysdate INTITLE,
'---------------------------------------------------------------------' LINECOL1,
'CIF: '||CIF CIF,
'EMPLOYEE NAME: '||EMPLOYEE_NAME EMPLOYEE_NAME,
'DEPARTMENT DETAILS: '||ORGANIZATION ORGANIZATION,
'---------------------------------------------------------------------' LINECOL2,
'ANNUAL LEAVE DETAILS:' ALHEADER,
'---------------------------------------------------------------------' LINECOL3,
'BALANCE B/F FROM PREVIOUS YEAR: '||BCEBF BCEBF,
'DAYS ENTITLED FOR THE CURRENT YEAR: '||ALDE ALDE,
'CURRENT YEAR REMAINING DAYS: '||CURYRREMDAYS CURYRREMDAYS,
'DAYS TAKEN FOR THE CURRENT YEAR: '||DAYS_TAKEN DAYS_TAKEN,
'---------------------------------------------------------------------' LINECOL4,
'REMAINING BALANCE: '||REMBCE REMBCE,
'---------------------------------------------------------------------' LINECOL5,
'---------------------------------------------------------------------' LINECOL6,
'ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:' ALHEADER2,
'---------------------------------------------------------------------' LINECOL7,
TO_CHAR('START DATE: '||ABSENCE_START_DATE||' '||'END DATE: '||ABSENCE_END_DATE||' '||'DAYS TAKEN : '||DAYS_TAKEN_ANAL) AL_DAYS_ANAL,
' '||chr(10) LINEempty11,
'-- End of Report -- '||chr(10) endREPORT,
'{{end}} '||chr(10) endLINE
FROM HB_V_AN_LEAV_SUM_DAYSTAKEN_REP
WHERE CIF IN ('098033','098024')
ORDER BY
beginLINE ,
winsecidLINE,
placeLINE ,
LINEempty1,
LINEempty2,
LINEempty3,
LINEempty4,
LINEempty5,
LINEempty6,
LINEempty7,
LINEempty8,
LINEempty9,
LINEempty10,
receiverLINE,
EMP_EMAIL_ADDRESS,
LINEHEADER ,
unitsLINE ,
lmLINE ,
INTITLE ,
LINECOL1,
CIF ,
EMPLOYEE_NAME ,
ORGANIZATION ,
LINECOL2 ,
ALHEADER ,
LINECOL3,
BCEBF ,
ALDE ,
CURYRREMDAYS ,
DAYS_TAKEN ,
LINECOL4 ,
REMBCE ,
LINECOL5 ,
LINECOL6 ,
ALHEADER2 ,
LINECOL7 ,
LINEempty11,
endREPORT,
endLINE
spool off
>>
The required output I want to get is:
<<
{{begin}}
{{winsecid 750612}}
{{place rbsemail.tif 0 0}}
{{from [email protected]}}
{{fax [email protected] }}
{{Subject Annual Leave Summary Report as at 04-APR-08 }}
{{units cm}}
{{lm 2.0}}
ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
CIF: 098024
EMPLOYEE NAME: Christou Christos Panteli
DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
ANNUAL LEAVE DETAILS:
BALANCE B/F FROM PREVIOUS YEAR: 9
DAYS ENTITLED FOR THE CURRENT YEAR: 27
CURRENT YEAR REMAINING DAYS: 24
DAYS TAKEN FOR THE CURRENT YEAR: -3
REMAINING BALANCE: 33
ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
START DATE: 04-JAN-08 END DATE: 04-JAN-08 DAYS TAKEN : 1
START DATE: 24-JAN-08 END DATE: 24-JAN-08 DAYS TAKEN : 1
START DATE: 20-FEB-08 END DATE: 20-FEB-08 DAYS TAKEN : 1
-- End of Report --
{{end}}
{{begin}}
{{winsecid 750612}}
{{place rbsemail.tif 0 0}}
{{from [email protected]}}
{{fax [email protected]}}
{{Subject Annual Leave Summary Report as at 04-APR-08 }}
{{units cm}}
{{lm 2.0}}
ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
CIF: 098033
EMPLOYEE NAME: Demetriou Elena Steliou
DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
ANNUAL LEAVE DETAILS:
BALANCE B/F FROM PREVIOUS YEAR: 15
DAYS ENTITLED FOR THE CURRENT YEAR: 27
CURRENT YEAR REMAINING DAYS: 25
DAYS TAKEN FOR THE CURRENT YEAR: -2
REMAINING BALANCE: 40
ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
START DATE: 15-JAN-08 END DATE: 15-JAN-08 DAYS TAKEN : 1
START DATE: 24-MAR-08 END DATE: 24-MAR-08 DAYS TAKEN : 1
-- End of Report --
{{end}}
>>
However the actual output we get from the above query is as follows:
<<
{{begin}}
{{winsecid 750612}}
{{place rbsemail.tif 0 0}}
{{from [email protected]}}
{{fax [email protected] }}
{{Subject Annual Leave Summary Report as at 04-APR-08 }}
{{units cm}}
{{lm 2.0}}
ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
CIF: 098024
EMPLOYEE NAME: Christou Christos Panteli
DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
ANNUAL LEAVE DETAILS:
BALANCE B/F FROM PREVIOUS YEAR: 9
DAYS ENTITLED FOR THE CURRENT YEAR: 27
CURRENT YEAR REMAINING DAYS: 24
DAYS TAKEN FOR THE CURRENT YEAR: -3
REMAINING BALANCE: 33
ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
START DATE: 04-JAN-08 END DATE: 04-JAN-08 DAYS TAKEN : 1
-- End of Report --
{{end}}
START DATE: 24-JAN-08 END DATE: 24-JAN-08 DAYS TAKEN : 1
START DATE: 20-FEB-08 END DATE: 20-FEB-08 DAYS TAKEN : 1
{{fax [email protected] }}
{{Subject Annual Leave Summary Report as at 04-APR-08 }}
{{units cm}}
{{lm 2.0}}
ANNUAL LEAVE SUMMARY REPORT AS AT 04-APR-08
CIF: 098033
EMPLOYEE NAME: Demetriou Elena Steliou
DEPARTMENT DETAILS: 003-031-010-314-03140-Special Projects
ANNUAL LEAVE DETAILS:
BALANCE B/F FROM PREVIOUS YEAR: 15
DAYS ENTITLED FOR THE CURRENT YEAR: 27
CURRENT YEAR REMAINING DAYS: 25
DAYS TAKEN FOR THE CURRENT YEAR: -2
REMAINING BALANCE: 40
ANNUAL LEAVE DAYS TAKEN ANALYSIS FOR THE CURRENT YEAR:
START DATE: 15-JAN-08 END DATE: 15-JAN-08 DAYS TAKEN : 1
-- End of Report --
{{end}}
START DATE: 24-MAR-08 END DATE: 24-MAR-08 DAYS TAKEN : 1
>>
IF ANYONE CAN HELP ON THIS I WOULD REALLY APPRECIATE IT!
THANKS A LOT!
Best regards,
Elena -
Multiple cases based on Columns In SQL Query
There is a SQL query given below, that query performs DateDIff operation by selecting max and min date according to
TCard OR you can say id,
here' the query
SELECT
--COUNT(DIFF)
Count(DATEDIFF(D, MinDate, MaxDate)/30) AS DIFF
FROM (
SELECT
MAX(TDate) AS MaxDate,
MIN(TDate) AS MinDate
FROM EDATA
GROUP BY TCard
)a
Group by DATEDIFF(D, MinDate, MaxDate)/30
Now i want to apply some kind of sorting in this query before performing DateDiff operation (sorting can be based on several parameters
like age, name etc. but 1 at a time according to the cases)
Now I want to know How to apply cases over this query and where?You can apply sorting based on certain condition however you need to include those columns in your subquery. On custom sorting check out this article
here:
e.g.
SELECT CountryName
FROM dbo.Country
ORDER BY CASE WHEN
CountryName = 'INDIA' THEN '1'
WHEN CountryName = 'CHINA' THEN
'2'
ELSE CountryName END ASC
If this post answers your query, please click "Mark As Answer" or "Vote as Helpful". -
How to insert data into BLOB column using sql
Hi all,
How to insert data into BLOB column directly using sql .
create table temp
a blob,
b clob);
SQL> /
Insert into temp values ('32aasdasdsdasdasd4e32','adsfbsdkjf') ;
ERROR at line 1:
ORA-01465: invalid hex number
Please help in this.Thanks,
P Prakashsee this
How to store PDF file in BLOB column without using indirect datastore -
How to load date column using sql loader
Hi,
I am trying to load a file using sql loader. my date value in the file is '2/24/2009 8:23:05 pm',
In control file for this column i specified like this
rec_date date ''mm/dd/yyyy hh:mi:ss pm"
But i am getting following error
not avalid month.
Thanks
sudheerHi,
Use this example as reference:
CTL file:
LOAD DATA
INFILE 'test.txt'
BADFILE 'test.bad'
truncate INTO TABLE T3
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '|' TRAILING NULLCOLS
dt_date DATE "mm/dd/yyyy hh:mi:ss pm")DAT file:
2/24/2009 8:23:05 pm
C:\ext_files>sqlldr hr/hr control=test.ctl
SQL*Loader: Release 10.2.0.1.0 - Production on Wed Jul 1 20:35:35 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Commit point reached - logical record count 1
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> desc t3;
Name Type Nullable Default Comments
DT_DATE DATE Y
SQL> select to_char(dt_date, 'mm/dd/yyyy hh24:mi:ss') from t3;
TO_CHAR(DT_DATE,'MM/DD/YYYYHH2
02/24/2009 20:23:05
SQL> Regards,
Edited by: Walter Fernández on Jul 1, 2009 8:35 PM - Adding example...
Edited by: Walter Fernández on Jul 1, 2009 8:38 PM
Edited by: Walter Fernández on Jul 1, 2009 8:41 PM - Fixing some information... -
Loading Images into LONG RAW column using SQL or PL/SQL
Hi!
I am trying to load images into a LONG RAW column. Can anybody tell me how to do this using SQL or PL/SQL. I do not want to use Forms to do this. And, I have a limitation using BLOBs.
Thanks in Advance,
Kotesh.You wrote that you cannot use a java class to insert a picture. We are working on a school project and HAVE to use java as a client and Oracle 7 as a server.
Can you tell us how this is to be done?
Thank you in advance,
Bart van der Heijden
Maybe you are looking for
-
Artifacting in Motion. Sample project, and a request for help inside.
Would anyone be willing to download this Motion project and see if any artifacting occurs, either on playback or export? I'm on an original 2.66 quad macpro with a x1900 GPU. i've had the entire system checked out by apple, and clean installed everyt
-
How do I change the width of a lead column in an enhanced layout ?
I have an enhanced layout in BPS that gets rendered in TPM (CRM2007) application. I need to increase the width of a lead column in this layout. I saw a bunch of methods in a BADI UPX_LAYOUT_RENDER. There is one to manipulate XML and another to manipu
-
Mac os 10.4 colors in Leopard
Is it possible to have white menu bar with blue apple in top left and blue spotlight in top right of the menu like in mac os tiger. Leopard interface (transition to marble one) is ugly. Apple should include multiple UI colors to choose from. can i ha
-
Hi, Iam uploading an Excel file from the local PC using the <htmlb:fileUpload> I wanted to read this uploaded file and create a document with the data in the cells on the excel. When iam trying to read i get the data in numbers. any ideas to read the
-
My program is using Queue of type Uri to create Queue of urls and then i'm using webbrowser to navigate each Uri from the Queue in it's turn and get the url(html) source content and save it to the hard disk. The problem is sometimes the text files on