Calling SQL experts to help write a query
Trying to find some help from some sql experts.
I was asked to help write a query showing each Dialed_Number, the associated Call_Type, and Script(s) in an ICM configuration.
All the data I’m looking for seems to be in the following tables:
Dialed_Number (DialedNumberString, EnterpriseName, DialedNumberID)
Call_Type (CallTypeID, EnterpriseName)
Dialed_Number_Map (DialedNumberID, CallTypeID)
Call_Type_Map (CallTypeID, MasterScriptID)
Master_Script (MasterScriptID, EnterpriseName)
Thus far, my query looks like this:
SELECT distinct Dialed_Number.DialedNumberString, Dialed_Number.EnterpriseName AS DN_Name, Call_Type.EnterpriseName AS Call_Type_Name,
Master_Script.EnterpriseName AS ScriptName
FROM Call_Type_Map CROSS JOIN
Call_Type CROSS JOIN
Dialed_Number CROSS JOIN
Dialed_Number_Map CROSS JOIN
Master_Script
However, it’s returning every possible combination (it was 10x worse before adding the word ‘distinct’)
Ideally, I’d like the results to just show one row for each Dialed_Number (assumes 1:1 ratio of DN to CallType).
e.g.:
DN_Name DialedNumberString CallType_Name ScriptName
Can anyone offer any guidance or suggestion?
Thanks Geoff,
I'd put this out on a couple different channels, and while yours is pretty good (I did remove the RoutingClientID from the where clause), I got another version that works just as well, and also includes DNs without CallTypes, and those which may have a CallType, but no script.
SELECT dn.DialedNumberString, dn.EnterpriseName AS Dialed_Number_Name, ct.EnterpriseName AS Call_Type_Name, ms.EnterpriseName AS Script_Name
FROM Dialed_Number dn
LEFT OUTER JOIN Dialed_Number_Map dnm ON dn.DialedNumberID = dnm.DialedNumberID
LEFT OUTER JOIN Call_Type ct ON dnm.CallTypeID = ct.CallTypeID
LEFT OUTER JOIN Call_Type_Map ctm ON ct.CallTypeID = ctm.CallTypeID
LEFT OUTER JOIN Master_Script ms ON ctm.MasterScriptID = ms.MasterScriptID
I believe the "joins" are supposedly more efficient, too.
Thanks for your contribution!
Similar Messages
-
SQL experts please help for a query
I have following table1.
What query can give the result as given below, SQL experts please help on this.
TABLE1
Event DATETIME
in 2/JAN/2010
out 2/JAN/2010
in 13/JAN/2010
out 13/JAN/2010
in 5/JAN/2010
out 5/JAN/2010
RESULT REQUIRED FROM THE SQL QUERY
COL1_IN COL2_OUT
2/JAN/2010 2/JAN/2010
13/JAN/2010 13/JAN/2010
5/JAN/2010 5/JAN/2010I tried to help, but this puzzles me.
Why is this not returning pre-selected set of rows, why it's doing some merge join cartezian ?
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> select * from table1;
EVENT DATETIME
in 2/JAN/2010
out 2/JAN/2010
in 13/JAN/2010
out 13/JAN/2010
in 5/JAN/2010
out 5/JAN/2010
6 rows selected.
SQL> explain plan for
2 with a as
(select datetime from table1 where event='in'),
b as
(select datetime from table1 where event='out')
select a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
Explained.
SQL> set wrap off
SQL> set linesize 200
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 185132177
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 9 | 288 | 8 (0)| 00:00:01 |
| 1 | MERGE JOIN CARTESIAN| | 9 | 288 | 8 (0)| 00:00:01 |
|* 2 | TABLE ACCESS FULL | TABLE1 | 3 | 48 | 3 (0)| 00:00:01 |
| 3 | BUFFER SORT | | 3 | 48 | 5 (0)| 00:00:01 |
|* 4 | TABLE ACCESS FULL | TABLE1 | 3 | 48 | 2 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
2 - filter("EVENT"='in')
4 - filter("EVENT"='out')
Note
- dynamic sampling used for this statement
21 rows selected.
SQL> with a as
(select datetime from table1 where event='in'),
b as
(select datetime from table1 where event='out')
select a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
COL1_IN COL2_OUT
2/JAN/2010 2/JAN/2010
2/JAN/2010 13/JAN/2010
2/JAN/2010 5/JAN/2010
13/JAN/2010 2/JAN/2010
13/JAN/2010 13/JAN/2010
13/JAN/2010 5/JAN/2010
5/JAN/2010 2/JAN/2010
5/JAN/2010 13/JAN/2010
5/JAN/2010 5/JAN/2010
9 rows selected.
SQL> -
SQL I need help with this query Please help
List the names of all the products whose weight unit measure is “Gram”. Order the list by product name. Do not use JOINS, but use the IN clause with a sub-query.
select Name
from UnitMeasure
where Name= 'Gram'
order by Name
I did this, but it seem that the requirement is different.As a guess:
Select Name from Product
where UnitMeasure in (Select Name from unitmeasure where name = 'Gram')
Andy Tauber
Data Architect
The Vancouver Clinic
Website | LinkedIn
This posting is provided "AS IS" with no warranties, and confers no rights. Please remember to click
"Mark as Answer" and "Vote as Helpful" on posts that help you. This can be beneficial to other community members reading the thread. -
Need help writting advanced query.
I am trying to make a column of a dynamic table display a
record count from a diffrent table, limited by the Id number from
the first table....
The dynamic table displays all records of mysql table `List`
List.id
List.name
I have a second mysql table `index`.
One of the columns of `index` is named Number and contains a
number that corosponds to a List.id record.
I have added a new column to the dynamic table
List.id | List.name | new column
I would like this new column to be a number. Which is the
number of records in mysql table `index` that contain the List.id
of that row...
Currently I can limit the recordset query by a entered
value..1,2,3 etc...
But I do not know how to filter or limit by the List.id of
the current row...
I tried this advanced query to no use...as it is not valid.
SELECT *
FROM `index`
WHERE Number = `List`.id
Thank you in advance for looking and for any help anyone can
give.
SawSaw_duuhst wrote:
> I am trying to make a column of a dynamic table display
a record count from a
> diffrent table, limited by the Id number from the first
table....
>
> The dynamic table displays all records of mysql table
`List`
> List.id
> List.name
>
> I have a second mysql table `index`.
> One of the columns of `index` is named Number and
contains a number that
> corosponds to a List.id record.
>
> I have added a new column to the dynamic table
> List.id | List.name | new column
>
> I would like this new column to be a number. Which is
the number of records in
> mysql table `index` that contain the List.id of that
row...
>
> Currently I can limit the recordset query by a entered
value..1,2,3 etc...
> But I do not know how to filter or limit by the List.id
of the current row...
>
> I tried this advanced query to no use...as it is not
valid.
> SELECT *
> FROM `index`
> WHERE Number = `List`.id
>
> Thank you in advance for looking and for any help anyone
can give.
> Saw
You need to combine the 2 tables using a JOIN and then use a
GROUP BY
with a COUNT in the SELECT.
Try this:
SELECT list.List.id, list.List.name, COUNT(index.List.id) AS
ListCount
FROM index INNER JOIN list ON index.List.id = list.List.id
GROUP BY list.List.id, list.List.name
Dooza -
SQL Experts, Please help!!
Hi
Here is my query:
select
--Element Details:
pet.element_name, pet.element_type_id, pet.reporting_name,
decode(pet.processing_type, 'R', 'Recurring', 'Nonrecurring') "Processing Type",
pet.EFFECTIVE_START_DATE, pet.EFFECTIVE_END_DATE,
--Run Result Details:
prr.run_result_id,
NVL(prrv.RESULT_VALUE, 0)"Extra Mileage Details",
decode(piv.name, 'Pay Value', 'Amount',
'Number of KMs', 'Total Kilometers Covered',
'Vehicle Registration No', 'Vehicle Registration No.')"Input Value",
--Assignment Details:
paa.assignment_id,
--Time Period
ptp.START_DATE, ptp.end_date,
ptp.period_name "Payroll Period"
from
hr.pay_element_types_f pet,
hr.pay_run_results prr,
hr.pay_run_result_values prrv,
hr.pay_input_values_f piv,
hr.pay_assignment_actions assact,
hr.per_all_assignments_f paa,
hr.pay_payroll_actions payroll,
hr.per_time_periods ptp
where
pet.ELEMENT_TYPE_ID = prr.ELEMENT_TYPE_ID
and prr.run_result_id = prrv.run_result_id
and piv.input_value_id = prrv.input_value_id
and assact.ASSIGNMENT_ACTION_ID = prr.ASSIGNMENT_ACTION_ID
and paa.ASSIGNMENT_ID = assact.ASSIGNMENT_ID
and payroll.payroll_action_id = assact.PAYROLL_ACTION_ID
and ptp.TIME_PERIOD_ID = payroll.time_period_id
and pet.element_name = 'IVTB Extra Mileage'
and ptp.end_date between pet.effective_start_date and pet.effective_end_date
and ptp.end_date between paa.EFFECTIVE_START_DATE and paa.EFFECTIVE_END_DATE
and ptp.end_date between piv.effective_start_date and piv.effective_end_date
and paa.payroll_id != 0
and paa.pay_basis_id != 0
When I get the results, I get the Pay Value, Kilometers and Vehicle Registration no. in rows. They are my 'input values' having different input ids, however, they have same run result id and thus. I want to display them as separate columns each with the heading 'Pay value' , 'Kilometers' etc. and display my run resulyt value below each heading.
Is this possible? Can someone plz guide me?
Thanks in advance.
Regards,
Aparna GupteThis should be possible with SQL*Plus reporting
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14357/ch6.htm#CHDBEAAB
think it will be something like this;
COLUMN Pay_Value NEW_VALUE V_pay_value NOPRINT
COLUMN Kilometers NEW_VALUE V_Kilometers NOPRINT
COLUMN Registration NEW_VALUE V_Registration NOPRINT
TTITLE LEFT 'Heading: ' V_pay_value,V_Kilometers,V_Registration SKIP 2
BREAK ON piv.name SKIP PAGE
select
--Element Details:
pet.element_name, pet.element_type_id, pet.reporting_name,
decode(pet.processing_type, 'R', 'Recurring', 'Nonrecurring') "Processing Type",
pet.EFFECTIVE_START_DATE, pet.EFFECTIVE_END_DATE,
--Run Result Details:
prr.run_result_id,
NVL(prrv.RESULT_VALUE, 0)"Extra Mileage Details",
decode(piv.name, 'Pay Value', 'Amount',
'Number of KMs', 'Total Kilometers Covered',
'Vehicle Registration No', 'Vehicle Registration No.')"Input Value",
--Assignment Details:
paa.assignment_id,
--Time Period
ptp.START_DATE, ptp.end_date,
ptp.period_name "Payroll Period"
from
hr.pay_element_types_f pet,
hr.pay_run_results prr,
hr.pay_run_result_values prrv,
hr.pay_input_values_f piv,
hr.pay_assignment_actions assact,
hr.per_all_assignments_f paa,
hr.pay_payroll_actions payroll,
hr.per_time_periods ptp
where
pet.ELEMENT_TYPE_ID = prr.ELEMENT_TYPE_ID
and prr.run_result_id = prrv.run_result_id
and piv.input_value_id = prrv.input_value_id
and assact.ASSIGNMENT_ACTION_ID = prr.ASSIGNMENT_ACTION_ID
and paa.ASSIGNMENT_ID = assact.ASSIGNMENT_ID
and payroll.payroll_action_id = assact.PAYROLL_ACTION_ID
and ptp.TIME_PERIOD_ID = payroll.time_period_id
and pet.element_name = 'IVTB Extra Mileage'
and ptp.end_date between pet.effective_start_date and pet.effective_end_date
and ptp.end_date between paa.EFFECTIVE_START_DATE and paa.EFFECTIVE_END_DATE
and ptp.end_date between piv.effective_start_date and piv.effective_end_date
and paa.payroll_id != 0
order by piv.name,Number of KMs,Vehicle Registration No -
Ordering according comparing - SQL Experts pls help
Hi All,
I want to measure the nearest points according to percentage between these points and order it.
by another way, i want to show the relation between points according to percentage value.
drop table temp_value;
create table temp_value(id number(10),location varchar2(20), percentage number(9));
insert into temp_value values (1,'LOC 1,2',30);
insert into temp_value values (2,'LOC 1,3',0);
insert into temp_value values (3,'LOC 1,4',0);
insert into temp_value values (4,'LOC 1,5',0);
insert into temp_value values (5,'LOC 1,6',50);
insert into temp_value values (6,'LOC 2,3',0);
insert into temp_value values(7,'LOC 2,4',0);
insert into temp_value values (9,'LOC 2,5',0);
insert into temp_value values (10,'LOC 2,6',10);
insert into temp_value values (11,'LOC 3,4',90);
insert into temp_value values (12,'LOC 3,5',80);
insert into temp_value values (13,'LOC 4,5',0);
insert into temp_value values (14,'LOC 4,6',0);
insert into temp_value values (15,'LOC 5,6',0); i want the output like this, the ordering of the point like this
4
3
5
6
1
2 or like this
6
1
2
4
3
5 if you ask me why this ordering i will say that
4 [90 percent between point 3,4 that mean can be 3,4 or 4,3]
3
5 [80 percent between 3,5 that mean can be 5 after 3,4]
6 [50 percent between 1,6 that mean can be 1,6 or 6,1 ]
1
2 [ 30 percent between 1,2 that mean can be 1,2 or 2,1] regards
Edited by: Ayham on Oct 6, 2012 10:18 AM
Edited by: Ayham on Oct 6, 2012 10:43 AM
Edited by: Ayham on Oct 6, 2012 8:04 PMreally i am happy to see you reply but the results is not correct
SQL> select A1.loc as Location, A1.rn as percentage, a2.rw as group_number from
asd a1,
2 (Select rn, row_number() over(order by rn desc) rw
3 from asd
4 group by rn) a2
5 where a1.rn = a2.rn;
LOCATION PERCENTAGE GROUP_NUMBER
4 90 1
3 90 1
5 80 2
3 80 2
6 50 3
1 50 3
2 30 4
1 30 4
6 10 5
2 10 5
6 0 6
LOCATION PERCENTAGE GROUP_NUMBER
6 0 6
5 0 6
5 0 6
5 0 6
5 0 6
4 0 6
4 0 6
4 0 6
4 0 6
3 0 6
3 0 6
LOCATION PERCENTAGE GROUP_NUMBER
2 0 6
2 0 6
2 0 6
1 0 6
1 0 6
1 0 6
28 rows selected.
SQL>it should be like this
LOC Group
3 1
4 1
5 1
1 2
6 2
2 2Edited by: Ayham on Oct 6, 2012 1:11 AM
Edited by: Ayham on Oct 6, 2012 1:11 AM -
Sql question how to write this query
This is my query:
SELECT msi.segment1 item, bsd.operation_code, bd.department_code,
bsd.operation_description
FROM mtl_system_items msi,
bom_operational_routings bort,
bom_operation_sequences bos,
bom_departments bd,
bom_operation_resources br,
bom_resources bor,
bom_standard_operations bsd
WHERE msi.inventory_item_id = bort.assembly_item_id
AND msi.organization_id = bort.organization_id
AND bort.routing_sequence_id = bos.routing_sequence_id
AND bos.department_id = bd.department_id
AND bd.department_id = bsd.department_id
AND bos.standard_operation_id = bsd.standard_operation_id
AND bos.operation_sequence_id = br.operation_sequence_id
AND bor.resource_id = br.resource_id
AND bos.reference_flag = 1
AND msi.organization_id = '82'
AND bos.disable_date IS NULL
GROUP BY msi.segment1,
bsd.operation_code,
bd.department_code,
bos.operation_description,
bsd.operation_description,
bor.resource_code
Which essentially produces this output:
Item Op code Dept Description
123 10 Warehouse Move parts
123 20 Assembly Finish Parts
123 30 Inspection Complete
I need to capture when the part goes into Inspection and from where it came, so in this case, From Assembly to Inspection.
I don't even know where to start
Thanks for any directionNot sure I've got the columns names right from your example, but does this get you started at all?
It sounds like you might need an analytic function like LAG or LEAD.
with t as
(select 123 item, 10 op, 'Warehouse' code, 'Move' dept, 'parts' description
from dual
union
select 123, 20, 'Assembly', 'Finish', 'Parts'
from dual
union
select 123, 30, 'Inspection', 'Complete',null
from dual)
select *
from (
select item, op, code, dept, description, lag(code) over (partition by item order by op) previous_code
from t
where code = 'Inspection';
ITEM OP CODE DEPT DESCR PREVIOUS_C
123 30 Inspection Complete AssemblyMessage was edited by:
dombrooks -
How to write named query if we want to use IN syntax in our sql statement?
I cannot find a suitable category about named query, so please move to appropriate place if there is any.
When we write named query, below statement is fine.
Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field1 = :input1"); q2.setParameter("input1", "value1");
Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)"); q2.setParameter("input1", "3633, 3644");
Can anyone suggest? Thanks.roamer wrote:
Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)");
q2.setParameter("input1", "3633, 3644");
Can anyone suggest?The above is in your code right? Not in some configuration file?
Then you do it the same way as with regular jdbc/sql.
1. You start with a collection of values - call it collection A.
1. Create a for loop that dynamically creates the string using 'bind' variables (whatever you want to call the 'colon' entity in the above).
2. Call the createQuery method using the string that was created
3. Create a second loop that iterates over A and populates with setParameter.
Pseudo code
Object[] A = ...
String sql = "SELECT o FROM Table1 as o WHERE field2 IN (";
for (int i=1; i <= A.length; i++)
if (i == 1)
sql += ":input" + i;
else
sql += ",:input" + i;
sql += ")";
Query q2 = em.createQuery(sql);
for (int i=1; i <= A.length; i++
q2.setParameter("input" + i, A[i-1]);
}By the way there is a jdbc forum. -
Hello everyone,
I just want to thank you in advance for all the help that you can give today.
I just started at a new Company, as a junior DBA, the previous person left. Before that person left he created a lot of SSIS packages and
turn them into jobs basically to refresh many different tables on the SQL server. The datas are being import from another datasource, which is why the SSIS packages was created so we can bring the datas over to SQL side. Whenever I want to create a new
SSIS Package for a new job, I always get the same failure as below...
"Error: 0xC0047062 at Data Flow Task, Source - Query [1]: System.OverflowException: Arithmetic operation resulted in an overflow.
at System.Data.Odbc.OdbcStatementHandle.RowCount(SQLLEN& rowCount)
at System.Data.Odbc.OdbcDataReader.GetRowCount()
at System.Data.Odbc.OdbcDataReader.FirstResult()
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments,
SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Odbc.OdbcCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.PreExecute()
at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPreExecute(IDTSManagedComponentWrapper90 wrapper)
Error: 0xC004701A at Data Flow Task, DTS.Pipeline: component "Source - Query" (1) failed the pre-execute phase and returned error
code 0x80131516.
Information: 0x40043009 at Data Flow Task, DTS.Pipeline: Cleanup phase is beginning.
Information: 0x4004300B at Data Flow Task, DTS.Pipeline: "component "Destination - GLCGLDS" (103)" wrote 0 rows.
Task failed: Data Flow Task
SSIS package "SSIS_GLCGLDS_GL.dtsx" finished: Failure.
The program '[16836] SSIS_GLCGLDS_GL.dtsx: DTS' has exited with code 0 (0x0)."
All the SSIS packages are failing for me, not just the one I created, even the ones that were working
before, the ones that were created by the previous person, I just went to Start Debugging and it would failed at the same exact stage
Below are the exact steps that I do to create the SSIS Package (based on the notes from previous person)
1. right click on SSIS Package and select sql server import and export wizard and click next
2. Select data source as .Net framework Data Provide for ODBC
3. Input Datasource, and driver as: TS ODBC Multi – Tier Driver
4. Choose destination as Microsoft OlE DB Provide for SQL Server
5. Write a basic select statement.
6. Click edit Mappings
7. Here's the important part... I am ABLE to preview the DATA.
8. Click ok next finished
9. Click debug start debugging
10. The preparation SQL task will be green, but the Data Flow Task will failed everytime for me.
If anyone has any suggestion please let me know, b/c I have try every possible ways and out of luck, and I don't want to explain to my boss
I don't know how to do it or how the previous person does it without any failures.
TLBelow are the exact steps that I do to create the SSIS
Package (based on the notes from previous person)
1. right click on SSIS Package and select sql server import and export wizard and click
next
2. Select data source as .Net framework Data Provide for ODBC
3. Input Datasource, and driver as: TS ODBC Multi – Tier Driver
4. Choose destination as Microsoft OlE DB Provide for SQL Server
5. Write a basic select statement. (select * from tableA)
6. Click edit Mappings to modify few column with their data type
7. Next -> Here's the important part... when I clicked on Preview Data, I am ABLE to
preview the DATA.
Finished. -
Crystal Report XI: Can you write your query in SQL instead of using the GUI
Hello
In crystal report version XI, can you write your query in sqlplus and then use the crystal report designer to build your report instead of using the GUI . I would like to be able to go database and show sql query and open that query and make changes directly there, is that possible on this version, if yes is there a setting somewhere? Please let me know.
Thank you
alphaMoved to Database forum.
No you can no longer modify the SQL directly. Use a Command Object to enter the SQL directly.
Thank you
Don -
Please help to re-write this query using exists or with
Hi please help to re-write this query using exists or with, i need to write same code for 45 day , 90 days and so on but sub query condition is same for all
SELECT SUM (DECODE (t_one_mon_c_paid_us, 0, 0, 1)) t_two_y_m_mul_ca_
FROM (SELECT SUM (one_mon_c_paid_us) t_one_mon_c_paid_us
FROM (
SELECT a.individual_id individual_id,
CASE
WHEN NVL
(b.ship_dt,
TO_DATE ('05-MAY-1955')
) >= SYSDATE - 45
AND a.country_cd = 'US'
AND b.individual_id in (
SELECT UNIQUE c.individual_id
FROM order c
WHERE c.prod_cd = 'A'
AND NVL (c.last_payment_dt,
TO_DATE ('05-MAY-1955')
) >= SYSDATE - 745)
THEN 1
ELSE 0
END AS one_mon_c_paid_us
FROM items b, addr a, product d
WHERE b.prod_id = d.prod_id
AND d.affinity_1_cd = 'ADH'
AND b.individual_id = a.individual_id)
GROUP BY individual_id)
Edited by: user4522368 on Aug 23, 2010 9:11 AMPlease try and place \ before and after you code \Could you not remove the inline column select with the following?
SELECT a.individual_id individual_id
,CASE
when b.Ship_dt is null then
3
WHEN b.ship_dt >= SYSDATE - 90
3
WHEN b.ship_dt >= SYSDATE - 45
2
WHEN b.ship_dt >= SYSDATE - 30
1
END AS one_mon_c_paid_us
FROM items b
,addr a
,product d
,order o
WHERE b.prod_id = d.prod_id
AND d.affinity_1_cd = 'ADH'
AND b.individual_id = a.individual_id
AND b.Individual_ID = o.Individual_ID
and o.Prod_CD = 'A'
and NVL (o.last_payment_dt,TO_DATE ('05-MAY-1955') ) >= SYSDATE - 745
and a.Country_CD = 'US' -
Help in calling sql loader and an oracle procedure in a script
Hi Guru's
please help me in writing an unix script which will call sql loader and also an oracle procedure..
i wrote an script which is as follows.
!/bin/sh
clear
#export ORACLE_SID='HOBS2'
sqlldr USERID=load/ps94mfo16 CONTROL=test_nica.ctl LOG=test_nica.log
retcode=`echo $?`
case "$retcode" in
0) echo "SQL*Loader execution successful" ;;
1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
3) echo "SQL*Loader execution encountered a fatal error" ;;
*) echo "unknown return code";;
esac
sqlplus USERID=load/ps94mfo16 << EOF
EXEC DO_TEST_SHELL_SCRIPT
it is loading the data in to an oracle table
but the procedure is not executed..
any valuable suggestion is highly appriciated..
Cheersmultiple duplicate threads:
to call an oracle procedure and sql loader in an unix script
Re: Can some one help he sql loader issue. -
Need a help to write the query
Hi,
I need a small help to write the query.
I have a table contains couponid,coupon,createdate,expirationdate,assigndate from couponday table
i want to write the query to select the coupon whose Expiry date in the table is NOT within 30 days.
Thanks in advanceHi,
user586 wrote:
i want to write the query to select the coupon whose Expiry date in the table is NOT within 30 days.If you mean expirationdate (datatype: DATE) is not within 30 days (past or future) of run time, then:
SELECT coupon -- or whatever columns you want
FROM table_x
WHERE expirationdate NOT BETWEEN SYSDATE - 30
AND SYSDATE + 30
; -
Hi
I have installed the required .Net software, but never the less I've got this message. Could you please help me out ?
Thanx in advance
Pia
TITLE: Microsoft SQL Server Management Studio
Cannot show Query Designer.
ADDITIONAL INFORMATION:
Exception has been thrown by the target of an invocation. (mscorlib)
Unable to find the requested .Net Framework Data Provider. It may not be installed. (System.Data)
BUTTONS:
OKalso check
http://connect.microsoft.com/VisualStudio/feedback/details/652192/visual-studio-2010-add-connection-fails
mostly machine.config is referring to .net 3.0 assemblies
Balmukund Lakhani
Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
This posting is provided "AS IS" with no warranties, and confers no rights.
My Blog |
Team Blog | @Twitter
| Facebook
Author: SQL Server 2012 AlwaysOn -
Paperback, Kindle -
SQL Experts I need help!!
I am trying to write a query that gives me a size summary of all the tables and indexes in my schema. I know this information can be obtained from USER_SEGMENTS, but I am having trouble structuring the query the way I would like. I would like the output of the query to be the following:
TABLE_NAME INDEX_NAME SIZE
TABLE_1............................... 50
................INDEX_TABLE_1_A....... 25
................INDEX_TABLE_1_B....... 30
(sub_total)........................... 105
TABLE_2.............................. 100
............... INDEX_TABLE_2_A...... 55
................INDEX_TABLE_2_B...... 50
................INDEX_TABLE_2_C...... 60
(sub_total)......................... 265
etc.........
As you can see I want it so that the query groups the indexes with the tables and then provides the total space consumed by each table and its indexes. I have tried many different methods to get these results to no avail. If anyone could give me some ideas I would greatly appreciate it.
PS I cannot use SQL*PLUS BREAK command
Message was edited by:
user616091Well since you can't use break you could probably use this:
select table_name, index_name, nvl(blocks, tot) blocks
from (
select ord, table_name, index_name, blocks,
sum(blocks)
over (partition by table_name
order by null
rows between unbounded preceding and unbounded following) tot
from (
select 1 ord,
nvl(table_name,segment_name) table_name,
nvl2(table_name,segment_name,null) index_name,
blocks
from user_segments left join user_indexes on index_name = segment_name
union all
select 2 ord,
segment_name table_name,
'Total' index_name,
null
from user_segments
where segment_type='TABLE'
and exists (select 1 from user_indexes where table_name = segment_name)
order by table_name, ord, index_name nulls first;
Maybe you are looking for
-
i have latest version of i tunes i.e. 11.2 and OS 7.1.1 but the photos are around 3000 in my laptop n only half of them i.e. 1500 and lesser are being syn to my iphone. i tried many tyms but the problem remains plz help me m fed up of installinhg and
-
Hi guys So here is what i have: i have a report which submit a concurrent request using fnd_request.submit_request* function. now my problem is profile information such as user_id, resp_id , resp_appl_id. i need those three profile information so i c
-
Tip: Unique Constraint on Part of Table
Here's a cute little trick I picked up from where it was hiding deep within one of the manuals: Consider a table where one column needs to be unique, but only part of the time based on some condition within the row. For example, col1 must be unique w
-
Lost format in Appleworks -- user error
Hello. I'm stumped by a problem I'm sure I inadvertently created. While becoming acquainted with Font Book, I managed to trash all the fonts, an embarrassment for someone who started years ago with a 512K Mac. I rescued them, dumped them back in the
-
Trouble connecting: Oracle Explorer
I got the .NET Oracle Developer installed, and even downloaded the Oracle database on my computer. In VS 2003 .NET, I can use Server Explorer and connect from Oracle Server fine. But in the Oracle Explorer, everytime I tried to connect it gives me th