Need help with PL/SQL query complex
I need help with a query that need access to data from 3 tables. That's what I didI created 3 tables
CREATE TABLE post_table
(
post_id varchar (20),
datepost DATE,
KEY (post_id) elementary SCHOOL
) ;
CREATE TABLE topic
(
TOPIC_ID varchar (20),
name varchar (20),
PRIMARY KEY (topic_id)
);
CREATE TABLE blogpost_table
(
TOPIC_ID varchar (20),
post_id varchar (20),
PRIMARY KEY (topic_id, post_id);
FOREIGN KEY (topic_id) REFERENCES topic (topic_id) ON DELETE CASCADE,
FOREIGN KEY (post_id) REFERENCES post_table (post_id) ON DELETE CASCADE
);
Now, I inserted a few values in these tables as
INSERT INTO post_table VALUES ('p1', to_date ('2009-09-14 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p2', to_date ('2009-07-18 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p3', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p4', to_date ('2009-03-11 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p5', to_date ('2009-07-13 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p6', to_date ('2009-06-12 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p7', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO VALUES subject ("t1", "baseball");
INSERT INTO category VALUES ('t2', 'football');
INSERT INTO blogpost_table VALUES ("t1", "p1");
INSERT INTO blogpost_table VALUES ('t1', 'p3');
INSERT INTO blogpost_table VALUES ("t1", "p4");
INSERT INTO blogpost_table VALUES ('t1', 'p5');
INSERT INTO blogpost_table VALUES ('t2', 'p2');
INSERT INTO blogpost_table VALUES ('t2', 'p6');
INSERT INTO blogpost_table VALUES ("t2", "p7");
I'm launching SQL queries on the table in this topic.
I want to write a SQL query that returns me the name of a topic (s) and the number of blog_post (s) associated with the topic in descending order of the number of blog posts created in July.
Can someone please help me to write this query?
Thank you
Published by: user11994430 on October 9, 2009 07:24
Thanks for the test of the configuration!
SQL>SELECT t.NAME, COUNT(*)
2 FROM topic t, blogpost_table b, post_table p
3 WHERE b.topic_id = t.topic_id
4 AND p.post_id = b.post_id
5 AND p.datepost >= DATE '2009-07-01'
6 AND p.datepost < DATE '2009-08-01'
7 GROUP BY t.NAME
8 ORDER BY COUNT(*) desc;
NAME COUNT(*)
-------------------- ----------
baseball 2
soccer 2
HTH, Urs
Tags: Database
Similar Questions
-
Hello
I have a data in table (raj_table) with columns (char11) raj_id, raj_number (varchar2 (15)), raj_format (NUMBER), Primary_ID (identity with the values of the primary key column)
Primary_ID raj_id Raj_number Raj_format
1 raj rajvend 1
2 raj rajvend 1
3 raj rajvendor1 2
4 raj rajvendor1 2
5 raj rajvendor1 2
6 raj rajvendor2 3
I used under SQL to get query output as below, but has not achieved the required result:
Select client_id vendor_number, vendor_format, primary_id, row_number() on sl_no (client_id partition, primary_id, vendor_format order of client_id primary_id, vendor_format, vendor_number, vendor_number)
from raj_table by sl_no asc
SL_NO raj_id raj_number raj_format primary_id
1 1 raj rajvendor 1
1 2 raj rajvendor 1
2 3 raj rajvendor1 2
2 4 raj rajvendor1 2
2 5 raj rajvendor1 2
3 6 raj rajvendor2 3
I need help with a SQL query to get the result as above without using the group by clause. I want to bring together the combination of separate line of the three columns (raj_id, raj_number, raj_format) and add a unique serial number for each online game (SL_NO column below). So, above there are 3 unique set of (raj_id, raj_number, raj_format) I can get in a group by clause, but I can not add prmiary_id, SL_NO values if I group by clause. I used the analytical functions like row_number() but no luck. Need solution for this.
with t as)
Select 'raj' raj_id, 'rajvend' raj_number, 1 raj_format, 1 primary_id Union double all the
Select option 2, 'raj', 'rajvend', 1 double Union all
Select 3, 'raj', 'rajvendor1', 2 double Union all
Select 4, 'raj', 'rajvendor1', 2 double Union all
Select 5, 'raj', 'rajvendor1', 2 double Union all
Select 6, 'raj', 'rajvendor2', 3 double
)
Select dense_rank() over (order of raj_id, raj_number, raj_format) sl_no,
t.*
t
order by primary_id
/
PRIMARY_ID RAJ RAJ_NUMBER RAJ_FORMAT SL_NO
---------- ---------- --- ---------- ----------
1 1 raj rajvend 1
1 2 raj rajvend 1
2 3 raj rajvendor1 2
2 4 raj rajvendor1 2
2 5 raj rajvendor1 2
3 6 raj rajvendor2 36 selected lines.
SQL >
SY.
-
Help with making SQL query references to column aliases in the Case statement
I need help with a sql query that I'm trying. I can go about it the wrong way, but I would be grateful if I could get any suggestions on possible solutions. This is my query:
SELECT DISTINCT spriden_pidm, spriden_id id, spriden_last_name | ',' | spriden_first_name name,
CASE
WHEN rcresar_comm_code_01 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_01
WHEN rcresar_comm_code_02 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_02
WHEN rcresar_comm_code_03 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_03
WHEN rcresar_comm_code_04 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_04
WHEN rcresar_comm_code_05 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_05
WHEN rcresar_comm_code_06 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_06
WHEN rcresar_comm_code_07 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_07
WHEN rcresar_comm_code_08 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_08
WHEN rcresar_comm_code_09 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_09
WHEN rcresar_comm_code_10 IN ('268 ', '269', ' 270') THEN rcresar_comm_code_10
END acg_elig_comm_code
CASE
WHEN acg_elig_comm_code = ' 268' THEN 'rigorous HS course. "
WHEN acg_elig_comm_code = '269' THEN ' 2 or several AP or IB"
WHEN acg_elig_comm_code = '270' THEN 'NOC as possible ".
END comm_code_description
OF spriden, rcresar, rcrapp1
WHERE (rcresar_comm_code_01 IN ('268 ', '269', ' 270')
OR rcresar_comm_code_02 ('268 ', '269', ' 270')
OR rcresar_comm_code_03 ('268 ', '269', ' 270')
OR rcresar_comm_code_04 ('268 ', '269', ' 270')
OR rcresar_comm_code_05 ('268 ', '269', ' 270')
OR rcresar_comm_code_06 ('268 ', '269', ' 270')
OR rcresar_comm_code_07 ('268 ', '269', ' 270')
OR rcresar_comm_code_08 ('268 ', '269', ' 270')
OR rcresar_comm_code_09 ('268 ', '269', ' 270')
OR rcresar_comm_code_10 ('268 ', '269', ' 270'))
Rcresar_aidy_code = & aidy_code
AND rcrapp1_aidy_code = rcresar_aidy_code
AND rcrapp1_curr_rec_ind = 'Y '.
AND rcrapp1_seq_no = rcresar_seq_no
AND spriden_pidm = rcresar_pidm
AND rcrapp1_pidm = rcresar_pidm
AND spriden_change_ind IS NULL
ORDER BY name
The second case statement is where I don't know exactly what it takes to get what I want.
Output should be like:
spriden_pidm name ID acg_elig_comm_code comm_code_description
«0000000000', ' 1111111111 ","John Doe","268", «rigorous HS race"»
If I take the second case statement it works great except that I do not have my comm_code description column. My question is how can I use my first statement value box to determine this column? I think that I need a case statement as I have, but I don't know how to reference the value of acg_elig_comm_code. Any help would be greatly appreciated. Thank you.
Published by: blackhole82 on January 20, 2009 09:20Hello
You cannot use the alias column in the query, even where it is set (except in the ORDER BY clause).
You can set the alias in a subquery and then use it in a great query, like this:WITH sub_q AS ( SELECT DISTINCT spriden_pidm,spriden_id id, spriden_last_name||', '||spriden_first_name name, CASE WHEN rcresar_comm_code_01 IN ('268','269','270') THEN rcresar_comm_code_01 WHEN rcresar_comm_code_02 IN ('268','269','270') THEN rcresar_comm_code_02 WHEN rcresar_comm_code_03 IN ('268','269','270') THEN rcresar_comm_code_03 WHEN rcresar_comm_code_04 IN ('268','269','270') THEN rcresar_comm_code_04 WHEN rcresar_comm_code_05 IN ('268','269','270') THEN rcresar_comm_code_05 WHEN rcresar_comm_code_06 IN ('268','269','270') THEN rcresar_comm_code_06 WHEN rcresar_comm_code_07 IN ('268','269','270') THEN rcresar_comm_code_07 WHEN rcresar_comm_code_08 IN ('268','269','270') THEN rcresar_comm_code_08 WHEN rcresar_comm_code_09 IN ('268','269','270') THEN rcresar_comm_code_09 WHEN rcresar_comm_code_10 IN ('268','269','270') THEN rcresar_comm_code_10 END acg_elig_comm_code -- Originally posted with , here (error) FROM spriden, rcresar, rcrapp1 WHERE (rcresar_comm_code_01 IN ('268','269','270') OR rcresar_comm_code_02 IN ('268','269','270') OR rcresar_comm_code_03 IN ('268','269','270') OR rcresar_comm_code_04 IN ('268','269','270') OR rcresar_comm_code_05 IN ('268','269','270') OR rcresar_comm_code_06 IN ('268','269','270') OR rcresar_comm_code_07 IN ('268','269','270') OR rcresar_comm_code_08 IN ('268','269','270') OR rcresar_comm_code_09 IN ('268','269','270') OR rcresar_comm_code_10 IN ('268','269','270')) AND rcresar_aidy_code = &aidy_code AND rcrapp1_aidy_code = rcresar_aidy_code AND rcrapp1_curr_rec_ind = 'Y' AND rcrapp1_seq_no = rcresar_seq_no AND spriden_pidm = rcresar_pidm AND rcrapp1_pidm = rcresar_pidm AND spriden_change_ind IS NULL ) SELECT sub_q.*, CASE WHEN acg_elig_comm_code = '268' THEN 'Rigorous HS course' WHEN acg_elig_comm_code = '269' THEN '2 or more AP or IB' WHEN acg_elig_comm_code = '270' THEN 'ACG possible' END comm_code_description FROM sub_q ORDER BY name
Furthermore, you might think to rearrange your table, so that you do not have 10 columns (rcresar_comm_code_01, rcresar_comm_code_02,...) that essentially do the same thing. The usual way to handle this kind of one-to-many relationship is to have all rcresar_comm_codes in a separate table, one per line, with a pointer to the table where you have them now.
Published by: Frank Kulash, January 20, 2009 11:35
Syntax error has been corrected -
Need help with Oracle SQL merge records according to date and term dates
Hi all
I need help to find this little challenge.
I have groups and flags and effective dashboards and dates of term against these indicators according to the following example:
GroupName Flag_A Flag_B Eff_date Term_date Group_A THERE THERE 20110101 99991231 Group_A N N 20100101 20101231 Group_A N N 20090101 20091231 Group_A N N 20060101 20081231 Group_A N THERE 20040101 20051231 Group_A THERE THERE 20030101 20031231 Group_B N THERE 20040101 99991231 Group_B N THERE 20030101 20031231 As you can see, group_A had the same combination of (N, N) flag for three successive periods. I want to merge all the time periods with the same indicators in one. Where entry into force will be the most early (underlined) time period and end date will be later (underlined)
So the final result should look like this:
GroupName Flag_A Flag_B Eff_date Term_date Group_A THERE THERE 20110101 99991231 Group_A N N 20060101 20101231 Group_A N THERE 20040101 20051231 Group_A THERE THERE 20030101 20031231 Group_B N THERE 20030101 99991231 Thanks for your help
Here's the DDL script
drop table TMP_group_test;
create table TMP_group_test (groupname varchar2 (8))
, flag_a varchar2 (1)
, flag_b varchar2 (1)
, eff_date varchar2 (8)
, term_date varchar2 (8)
);
insert into TMP_group_test values ('Group_A', 'Y', 'Y', ' 20110101 ', ' 99991231');
insert into TMP_group_test values ('Group_A', 'n', ' n ', ' 20100101 ', ' 20101231');
insert into TMP_group_test values ('Group_A', 'n', ' n ', ' 20090101 ', ' 20091231');
insert into TMP_group_test values ('Group_A', 'n', ' n ', ' 20060101 ', ' 20081231');
insert into TMP_group_test values ('Group_A', 'n', 'Y', ' 20040101 ', ' 20051231');
insert into TMP_group_test values ('Group_A', 'Y', 'Y', ' 20030101 ', ' 20031231');
insert into TMP_group_test values ('Group_B', 'n', 'Y', ' 20040101 ', ' 99991231');
insert into TMP_group_test values ('Group_B', 'n', 'Y', ' 20030101 ', ' 20031231');
commit;
Post edited by: user13040446
It is the closest, I went to the solution
I create two rows;
Rnk1: partition by group name, order of eff_date / / desc: this grade will sort the records of the most recent and handed to zero for each group\
Rnk2: (dense) partition by group name, flag_A, flagb: this grade for each combination of group\flag gives a number so that they are classified as "families".
Then I use the function analytic min
Min (eff_date) more (partition of GroupName, rnk2): the idea is that, for each Member of the same family, the new date is the min of the family (and the max for the date of the term), at the end I just need separate so that the duplicates are gone
Now the problem. As you can see from the query below, records of 1 and 6 (as identified by rownum) are identified in the same family, because they have the same combination of flag, but they are not successive, so everyone must keep its own date of entry into force.
If only I can make the distinction between these two that would solve my problem
Query:
Select rowNum,GroupName, flag_a, flag_b, eff_date, term_date, rnk1, rnk2
, min (eff_date) more than (partition by GroupName rnk2( ) min_eff
Of
(
Select rowNum,
GroupName , flag_a , flag_b , eff_date , term_date
rank() more than (partition by GroupName stopped by eff_date desc) rnk1
DENSE_RANK() more than (partition by GroupName order by flag_A flag_B ( ) rnk2
de dsreports . tmp_group_test
) order by rowNum
Hello
user13040446 wrote:
Hi KSI.
Thanks for your comments, you were able to distinguish between these lines highlight, but lost lines 2,3,4 which are supposed to have the same date min = 20060101.
Please see the table wanted to see the final result I want to reach
Thanks again
This first answer is basically correct, but in the main query, you want to use the function MIN, not the analytical function aggregation and GROUP BY columns with common values, like this:
WITH got_output_group AS
(
SELECT GroupName, flag_a, flag_b, eff_date, term_date
ROW_NUMBER () OVER (PARTITION BY GroupName
ORDER BY eff_date
)
-ROW_NUMBER () OVER (PARTITION BY GroupName, flag_a, flag_b)
ORDER BY eff_date
) AS output_group
OF tmp_group_test
)
SELECT GroupName, flag_a, flag_b
MIN (eff_date) AS eff_date
MAX (term_date) AS term_date
OF got_output_group
GROUP BY GroupName, flag_a, flag_b
output_group
ORDER BY GroupName
eff_date DESC
;
The result I get is
GROUP_NA F F EFF_DATE TERM_DAT
-------- - - -------- --------
Group_A Y 20110101 99991231 Y
N Group_A 20101231 20060101 N
Group_A N 20051231 20040101 Y
Group_A Y Y 20031231-20030101
Group_B N Y 99991231 20030101
which is what you asked for.
-
Need help with PL/SQL so and then select
Hello guys, I am new to the PL/SQl programming (only Java experience) and I'm pretty stuck to my task. It would be great if you could help me. I am in programming with Oracle SQL * Plus Version 10.2.0.3.0
Whenever a user logs on to the server a database entry is created with information about the logged-on user. I need to create a PL/SQL command that selects all the information from last month. Unfortunately, the date_stamp column has a certain weird format: 1131210 for December 10, 2013
My idea so far:
DECLARE
v_today NUMBER;
BEGIN
v_today: = TO_NUMBER (TO_CHAR (SYSDATE, 'MM')); -Save the number of the month (e.g.12) in v_today
IF v_today = 01 THEN
SELECT * from audittrl
WHERE the date_stamp between 1131201 AND the 1131231;
ELSIF v_today = 02 THEN
SELECT * from audittrl
WHERE the date_stamp between the 1130131 AND 1130101;
.......
END IF;
END;
/
Error code: "an INTO clause in this SELECT statement.
I do not want to save the result to select a variable, hope you can help me. Thanks in advance.
Hello
6a4d1bcd-c00e-4dac-AB64-9b6bdb1652d1 wrote:
Thanks, I'll try that, if still get caught once, I'll be back. Anway I'm not sure of the solution of Chris227, because I can't test it right now. From my point of view it gives you information the current month (e.g., December) and not the month previous (-online November), or have I missed something. ?
You are right. In addition, it does not for a given year. If you have data from several years in the table, it will select lines for the month of December 2012, 2011, 2010,... but also of 2013.
Here's a way to get around that:
DECLARE
prev_month_start PLS_INTEGER: = TO_NUMBER (TO_CHAR (ADD_MONTHS (SYSDATE-1)
, "YYMM"1' "01"
)
);
this_month_start PLS_INTEGER: = TO_NUMBER (TO_CHAR (SYSDATE
, "YYMM"1' "01"
)
);
BEGIN
FOR (IN) rec
SELECT *.
Of audittrl
WHERE the date_stamp > = prev_month_start
AND date_stamp< > >
ORDER BY user_id, date_stamp - or other)
LOOP
dbms_output.put_line (rec.date_stamp);
dbms_output.put_line (rec.event);
dbms_output.put_line (rec.user_id)
dbms_output.put_line (rec.host_name);
END LOOP;
END;This should also be more effective, because it will allow the optimizer to use an index on date_stamp. Even if there is no index, it will be more effective because it avoids calling any function (for example, SUBSTR) on each line of the table.
You needn't PL/SQL to get these results. Just use SQL, you might say:
SELECT event, host_name, user_id and date_stamp
Of audittrl
WHERE the date_stamp > = TO_NUMBER (TO_CHAR (ADD_MONTHS (SYSDATE-1)
, "YYMM"1' "01"
)
)
AND date_stamp< to_number="" (="" to_char="" (="" sysdate="" to_number="" (="" to_char="" (=""> >
, "YYMM"1' "01"
)
)ORDER BY user_id, date_stamp - or other
;
Your front end will provide column headers and touch the data so that the columns line up. It can also set the output to a file. (For example, if your front-end is SQL * Plus, you can use the command of the COIL.)
I guess date_stamp is a NUMBER. If it is a string, the solutions above can be simplified a bit.
This problem (and many other problems) would be so much simpler if date_stamp was a DATE column. Using numbers or strings to store the date information is simply asking for trouble.
-
Need help with writing a query
Hi all
Can someone help please write a query for the following scenario
Data in the table are in the format below
student_name Sub1 sub1_marks Sub2 sub2_marks SUB3 sub3_marks John Math 90 Science 80 lang 85 Need to write a query to get it as
student_name Object brands of John Math 90 John Science 80 John lang 85
Thank youI'm looking so unpivoting the mulitple columns option is there. how it will be used
I certainly learned something new today.
create table student_marks( student_name varchar2(20), sub1 varchar2(20), sub1_marks number, sub2 varchar2(20), sub2_marks number, sub3 varchar2(20), sub3_marks number ) ; insert into student_marks values( 'john', 'math', 90, 'science', 80, 'lang', 85 ) ; select student_name, sub subject, marks from student_marks unpivot include nulls ( (sub, marks) for subject in ( (sub1, sub1_marks), (sub2, sub2_marks), (sub3, sub3_marks) ) ) ; drop table student_marks purge ; table STUDENT_MARKS created. 1 rows inserted. STUDENT_NAME SUBJECT MARKS -------------------- -------------------- ---------- john math 90 john science 80 john lang 85 table STUDENT_MARKS dropped.
-
[Help] Need help with php, Sql variables
I have a users table contain fiedls "old, new and total."
When file, update user DEFINED total is $total
where $total = old + $nouveauI did it, I used echo to make sure it's ok, but it's not:
/ * Variable total Count * /.
$old = ['old'] $row_rs_users;
$new = $row_rs_users ['new'];
$total = $vieux + $new;
echo $total;
If ((isset($_POST["MM_update"])) & & ($_POST ["MM_update"] == "doit_form")) {}
$updateSQL = sprintf ("UPDATE users SET total = WHERE id = %s %s",)
$total,
GetSQLValueString ($_POST ['id'], "int"));Thank you
As a part of your code, it is impossible to debug.
However, your approach is bad anyway. All you need to do is add the new value to the old in the SQL query.
$updateSQL = sprintf("UPDATE users SET total=(total+%s) WHERE id=%s", GetSQLValueString($_POST['fieldName'], "double"), GetSQLValueString($_POST['id'], "int"));
$_POST ['fieldName'] is the new value. Use the 'double' if the value contains a decimal point. If it is an integer, replace 'double' 'int '.
-
Hi all
Here is the sql query,
Select papf.employee_number,
-papf.full_name, ppa.effective_date, pp.payroll_name,
PET.element_name,
PIV. Name input_value,
prrv.result_value
-, ppa.payroll_action_id, ppa.time_period_id
Of
Apps.pay_payroll_actions App,
pay_assignment_actions AAP,
pay_payrolls_f pp,
pay_run_results prr,
prrv pay_run_result_values,
pay_input_values_f piv,
animal pay_element_types_f,
Apps.per_all_assignments_f ADP,
Apps.per_all_people_f women's wear
-where ppa.payroll_action_id =: payroll_action_id - give your payroll_action_id
where ppa.payroll_id =: payroll_id
and ppa.payroll_action_id =: payroll_action_id
- and paa.assignment_action_id =: assignment_action_id
and ppa.payroll_action_id = paa.payroll_action_id
and ppa.payroll_id = pp.payroll_id
and paa.assignment_action_id = prr.assignment_action_id
and prr.run_result_id = prrv.run_result_id
and prrv.input_value_id = piv.input_value_id
and piv.element_type_id = pet.element_type_id
and paaf.assignment_id = paa.assignment_id
and paaf.person_id = papf.person_id
and trunc (sysdate) between pp.effective_start_date and pp.effective_end_date
and trunc (sysdate) between pet.effective_start_date and pet.effective_end_date
and trunc (sysdate) between piv.effective_start_date and piv.effective_end_date
and trunc (sysdate) between paaf.effective_start_date and paaf.effective_end_date
and trunc (sysdate) between papf.effective_start_date and papf.effective_end_date
- and papf.employee_number = '1'
- and ppa.effective_date = July 22, 2014"
and pet.element_name in ('Local Mission allowance', "Compensation of Mission International")
order by 1.3
The result is:
Employee_number Element_Name Input_Value Result_value
1 compensation of Mission international day amount 1000
1 compensation of international Mission Distance days 4
1 value to pay compensation of 1200 International Mission
1 International Mission allowance Start Date 01/01/2014
1 compensation of Mission international day amount 800
1 compensation of international Mission Distance days 10
1 International Mission allowance pay value 2000
1 International Mission allowance Start Date 01/02/2014
1 compensation of Mission local day amount 500
1 compensation of local Mission Distance days 10
1 Mission allowance paid local value 1000
1 compensation of local Mission Start Date 01/11/2014
Desired output:
Employee_number Element_Name Day_Amount Distance_Days Pay_Value Start_Date
1 compensation of international Mission 1000, 1200 4 2014/01/01
1
International Mission allowance 800 10 2000 01/02/2014 1 Mission local compensation 500 10 1000 01/11/2014 Please suggest.
INSERT statement:
TOGETHER TO DEFINE
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Day amount', '1000');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Day amount', '1000');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'number of orders', '196');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'number of orders', '195');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', ' Distance days, 4 ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', ' Distance days, 1 ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
("1', 'International Mission allowance', 'employee Category", "scale of employment medical cities");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
("1', 'International Mission allowance', 'employee Category", "scale of employment medical cities");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Class level', 'G3');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Class level', 'G3');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'class of employment, ' ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'class of employment, ' ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Country of Mission', ' 3003 - Kuwait ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'Country of Mission', ' 2004 - Canada ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', ' Mission days, 4' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', ' Mission days, 3' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'compensation of Mission international","End of Mission Date"' 2014/07/10 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'compensation of Mission international","End of Mission Date"' 2014/07/19 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'compensation of Mission international", 'Mission Start Date', ' 2014/07/07 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'compensation of Mission international", 'Mission Start Date', ' 2014/07/17 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'value of pay', '3000');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('1', 'International Mission allowance', 'value of pay', '4000');
00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'number of orders', '45');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'number of orders', "456789");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', ' away days '0' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', ' Distance days, 1 ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', 'Provided food', 'Y');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'compensation of local Mission","Accommodation provided", 'Y');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'compensation of local Mission","Accommodation provided", 'Y');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', "local Mission allowance", "Mission City", "AL MEDINA");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', "local Mission allowance", "Mission City", "RIYADH");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', ' Mission days, 4' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70 ', 'local Mission allowance', ' Mission days, 5' ");
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'End of Mission Date' ' 2014/06/16 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'End of Mission Date' ' 2014-06-14 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'Mission Start Date', ' 2014/06/13 00:00:00 ');
Insert into APPS. PER_ALL_PEOPLE_F
(EMPLOYEE_NUMBER, NOM_ELEMENT, INPUT_VALUE, RESULT_VALUE)
Values
('70', 'Local Mission allowance', 'Mission Start Date', ' 2014/06/10 00:00:00 ');
Thank you very much in advance.
Kind regards
Afzal.
So then... something like this:
SELECT employee_number
element_name
MAX (decode (input_value, 'Day amount', result_value)) AS day_amount
MAX (decode (input_value, 'Days of Distance', result_value)) AS Distance_Days
, MAX (decode (input_value, 'Value of pay', result_value)) AS Pay_Value
MAX (decode (input_value, 'Start Date', result_value)) AS Start_Date
from (SELECT papf.employee_number
pet.element_name
piv.NAME input_value
prrv.result_value
prrv.run_result_id
OF apps.pay_payroll_actions App
pay_assignment_actions PAA
pay_payrolls_f pp
pay_run_results prr
pay_run_result_values prrv
pay_input_values_f piv
pay_element_types_f pet
apps.per_all_assignments_f ADP
apps.per_all_people_f women's wear
-where ppa.payroll_action_id =: payroll_action_id - give your payroll_action_id
WHERE ppa.payroll_id =: payroll_id
AND ppa.payroll_action_id =: payroll_action_id
- and paa.assignment_action_id =: assignment_action_id
AND ppa.payroll_action_id = paa.payroll_action_id
AND ppa.payroll_id = pp.payroll_id
AND paa.assignment_action_id = prr.assignment_action_id
AND prr.run_result_id = prrv.run_result_id
AND prrv.input_value_id = piv.input_value_id
AND piv.element_type_id = pet.element_type_id
AND paaf.assignment_id = paa.assignment_id
AND paaf.person_id = papf.person_id
AND trunc (sysdate) BETWEEN pp.effective_start_date AND pp.effective_end_date
AND trunc (sysdate) BETWEEN pet.effective_start_date AND pet.effective_end_date
AND trunc (sysdate) BETWEEN piv.effective_start_date AND piv.effective_end_date
AND trunc (sysdate) BETWEEN paaf.effective_start_date AND paaf.effective_end_date
AND trunc (sysdate) BETWEEN papf.effective_start_date AND papf.effective_end_date
AND pet.element_name IN ('local Mission allowance', 'International Mission'))
GROUP BY employee_number
element_name
run_result_id
;
You should get your desired result.
Roger
-
IP number looking for PSI - need help with a sql solution better and faster
Hello
I have a table (one) with more 1 000 000 IP addresses and numbers (the digital equivalent of the IP address)
I have a second table (b) which contains a mapping between the ranges of the ISP and IP. The table looks like this and more contains 150 000 entries:
BEGIN_IP_RANGE END_IP_RANGE ISP_NAME
-------------------------- ---------------------- --------------
600000000 700000000 ISP_X
800000000 900000000 ISP_Y
I'm creating a third table (c) which connects (a) IP numbers to identify the ISP from (B). The query looks like this:
CREATE TABLE c
AS
Select a.IP_ADDRESS
b.ISP_NAME
IP_NUMBERS a, ISP_LOOKUP b lkp
where a.IP_NUMBER between b.BEGIN_IP_RANGE and b.END_IP_RANGE
;
There is no key join between the 2 tables and so I use TO search for the access provider. The performace of it's terrible and table (c) takes several hours to create.
Does anyone have any thoughts/ideas/suggestions on how this research can be achieved by using a solution better and faster?
Thank you very much
Shah
The performace of it's terrible and table (c) takes several hours to create.
Hours what do you say?
See if the following can help.
Cardinalities are similar to yours. The ETG takes 7sec. :
SQL> create table ip_numbers (ip_address, ip_number) as 2 select cast(to_char(level,'fm099G999G999G999', 'nls_numeric_characters=,.') as varchar2(15)) 3 , level 4 from dual 5 connect by level <= 1000000 ; Table created. SQL> select * from ip_numbers where rownum <= 10; IP_ADDRESS IP_NUMBER --------------- ---------- 000.000.000.001 1 000.000.000.002 2 000.000.000.003 3 000.000.000.004 4 000.000.000.005 5 000.000.000.006 6 000.000.000.007 7 000.000.000.008 8 000.000.000.009 9 000.000.000.010 10 10 rows selected. SQL> SQL> create table isp_lookup (begin_ip_range, end_ip_range, isp_name) as 2 select 1 + (level-1)*5 3 , level*5 4 , cast('ISP_'||to_char(level,'fm099999') as varchar2(10)) 5 from dual 6 connect by level <= 200000 ; Table created. SQL> select * from isp_lookup where rownum <= 10; BEGIN_IP_RANGE END_IP_RANGE ISP_NAME -------------- ------------ ---------- 1 5 ISP_000001 6 10 ISP_000002 11 15 ISP_000003 16 20 ISP_000004 21 25 ISP_000005 26 30 ISP_000006 31 35 ISP_000007 36 40 ISP_000008 41 45 ISP_000009 46 50 ISP_000010 10 rows selected. SQL> create index ip_address_number_ix on ip_numbers (ip_number); Index created. SQL> set timing on SQL> SQL> create table ip_mappings as 2 select /*+ use_nl(a b) */ 3 a.ip_address 4 , b.isp_name 5 from isp_lookup b 6 join ip_numbers a on a.ip_number between b.begin_ip_range 7 and b.end_ip_range 8 ; Table created. Elapsed: 00:00:06.94 SQL> select count(*) from ip_mappings; COUNT(*) ---------- 1000000 Elapsed: 00:00:01.22
-
Need help with an update query
Hello
I am trying to run a query on a table update. Here's an example: I have 2 tables t1 and t2, and these tables have 2 similar columns, c11 and c12 in t1 and c21 and c22 in t2. I now have to execute an update statement for the column c11 in t1 with the values for the c21 in t2 where the c12 in t1 is equal to c22 in t2. Therefore, the request that I made:
Update t1 set c11 =.
(select t2.c21 from t1, t2 where t1.c11 = t2.c22)
where t1.c11 in (select t1.c11 from t1);
But this query gives me an error: ORA-01427: einreihig subquery returns more than one line.
Where I'm going wrong? Kindly help.Hello
Try
UPDATE t1 SET c11 = (SELECT t2.c21 FROM t2 WHERE t1.c12 = t2.c22) WHERE EXISTS (SELECT 1 FROM t2 WHERE t1.c12 = t2.c22);
When you say
c12 in t1 is equal to c22 in t2
your where clause should be like
WHERE t1.c12 = t2.c22
and you do not need to join the table updated in the subquery that you can refer directly to its columns.
from t1,t2--not needed. Use FROM t2
* 009 *.
Published by: 009 on March 18, 2010 21:04
-
Need help with PL/SQL code
Hi I am writing this code in pl/SQL:
create or replace
PROCEDURE 'TESTPRI '.
(NUMBER pCYC_DT)
AS
vTGT_TABL VARCHAR2 (25);
vSTG_TABL varchar2 (30);
vsql varchar2 (200);
BEGIN
vTGT_TABL: = 'TESTTABL ';
vSTG_TABL: = vTGT_TABL | » _'|| pCYC_DT;
vsql: = 'TRUNCATE TABLE ' | vTGT_TABL;
EXECUTE IMMEDIATE vsql;
RUN IMMEDIATELY "INSERT" | vTGT_TABL | ' SELECT * FROM '. vSTG_TABL;
COMMIT;
-IMMEDIATE 'TRUNCATE TABLE ' | vSTG_TABL;
END TESTPRI;
When executing this procedure it gives me following error:
ORA-03290: Invalid command truncate - lack of key word TABLE or CLUSTER
ORA-06512: at "DBR. TESTPRI', line 11
ORA-06512: at line 6
But I think that the TRUNCATE TABLE statement is correct. Is there a problem with the variable?
Any help would be appreciated.
Thank you.vsql: = 'TRUNCATE TABLE ' | vTGT_TABL;
You need space after the TABLE
vsql:= 'TRUNCATE TABLE ' ||vTGT_TABL ;
EXECUTE IMMEDIATE vsql;
RUN IMMEDIATELY "INSERT" | vTGT_TABL | ' SELECT * FROM '. vSTG_TABL;Sapce here after INTO, before SELECT and FROM
EXECUTE IMMEDIATE 'INSERT INTO '|| vTGT_TABL||' SELECT * FROM '|| vSTG_TABL;
-
Hello
I use oracle 10g and having some small doubts associated with sql, goes here of the situation
I have a Transaction table, which contains the records/operation made by an employee under a code of pattern on different dates, see below examples of data
Actually I want to have the final result as follows (p. ex. some how hide A003, see below for reason)EMP_CODE REASON_CODE DATE A001 B1 1st Jan 2009 A001 B1 3rd Jan 2009 A001 B1 6rd Jan 2009 A001 C2 9th Jan 2009 A002 D4 1st Jan 2009 A002 D4 3rd Jan 2009 A002 D5 6rd Jan 2009 A003 E6 6rd Jan 2009 A003 E6 7rd Jan 2009
So basically, print employee ID and reason code only if the employee has made the transaction under more than 1 code of reason, since the employee "A003" completed transaction code Minus 1 SINGLE code ONLY reason *, I don't want his record in printed.*A001 B1 A001 C2 A002 D4 A002 D5
the current query I wrote is as follows:
but this impression of results asselect emp_cd, reas_cd from employee_trans_table where reas_cd <> ' ' group by emp_cd, reas_cd order by emp_cd, reas_cd
How to avoid printing A003/E6 since she had only 1 reason code attached to it...A001 B1 A001 C2 A002 D4 A002 D5 *A003 E6*
I hope that I am able to clearly state the doubt that I am, let me know if you need any other info/clarrification on it.
Concerning
Learner
Published by: learner1 on October 26, 2009 13:33
Published by: learner1 on October 26, 2009 13:34
Published by: learner1 on October 26, 2009 13:36
Published by: learner1 on October 26, 2009 13:36 (added code tag)A possible solution.
with data as ( select 'A001' as col1, 'B1' as col2 from dual union all select 'A001' as col1, 'B1' as col2 from dual union all select 'A001' as col1, 'B1' as col2 from dual union all select 'A001' as col1, 'C2' as col2 from dual union all select 'A002' as col1, 'D4' as col2 from dual union all select 'A002' as col1, 'D4' as col2 from dual union all select 'A002' as col1, 'D5' as col2 from dual union all select 'A003' as col1, 'E6' as col2 from dual union all select 'A003' as col1, 'E6' as col2 from dual ) select distinct col1, col2 from ( select col1, col2, count(distinct col2) over (partition by col1) as distinct_count from data ) where distinct_count != 1
-
Hi Experts,
I have a table W_data where there are 2 fields (1) business_date and (2) ID Business_date is a date field havgnd dates daily while id is to have an id associated with each date. So, for a date, there is always a single record.
I need to write a query so that I can retrieve the records for every sixth month by selecting the date of the minimum activity.
Please advice.
Thanks in advance.
So far you have not posted an expected output.
If you would like the earliest date in each half of the year and its corresponding ID, then
Select min (WAH_BUSINESS_DATE), min (id), Dungeon (dense_rank of the first order by WAH_BUSINESS_DATE)
of w_data
Trunc ((to_number (to_char (WAH_BUSINESS_DATE, 'yyyyq') Group) + 1) / 2).
Trunc (to_number(to_char...)) is to get a separate value for each semester, convert a different value of Q1 2013 and 2013 Q2 in a value and 2013 Q3 Q4 2013.
On your published data, which gives:
Date ID
-------------------- ----------
July 1, 2011 00:00:00 208596038
January 1, 2012 00:00:00 223976512
July 1, 2012 00:00:00 239761627
January 1, 2013 00:00:00 256223102
1 July 2013 00:00:00 272492185
-
Need help with a SQL qurey that returns multiple lines for a record?
I have the following query where I use a WHEN clause CASES to determine the date of a change that starts with 'FRLO' on day 1 - day14 of the pay period. It works fine if a folder schedule with a day that begins "FRLO", but if more than one day is "FRLO" then it only returns the first day he finds and not others. Is there a way to get the query to return a ron for every day 1-14 that begins "FRLO"? System if Oracle 11 G
The order of the results is not important, because this is part of a larger query that orders the results.
Thanks in advance for any help,
George
---------------------------------------------------------------------------------------------------------------------------------
SELECT s.empid,
CASE
A SUPERIOR TIME (SUBSTR (s.Day1, 0, 4)) = "FRLO".
THEN
pp.startpp
A SUPERIOR TIME (SUBSTR (s.Day2, 0, 4)) = "FRLO".
THEN
pp.startpp + 1
A SUPERIOR TIME (SUBSTR (s.Day3, 0, 4)) = "FRLO".
THEN
pp.startpp + 2
A SUPERIOR TIME (SUBSTR (s.Day4, 0, 4)) = "FRLO".
THEN
pp.startpp + 3
A SUPERIOR TIME (SUBSTR (s.Day5, 0, 4)) = "FRLO".
THEN
pp.startpp + 4
A SUPERIOR TIME (SUBSTR (s.Day6, 0, 4)) = "FRLO".
THEN
pp.startpp + 5
A SUPERIOR TIME (SUBSTR (s.Day7, 0, 4)) = "FRLO".
THEN
pp.startpp + 6
A SUPERIOR TIME (SUBSTR (s.Day8, 0, 4)) = "FRLO".
THEN
pp.startpp + 7
A SUPERIOR TIME (SUBSTR (s.Day9, 0, 4)) = "FRLO".
THEN
pp.startpp + 8
A SUPERIOR TIME (SUBSTR (s.Day10, 0, 4)) = "FRLO".
THEN
pp.startpp + 9
A SUPERIOR TIME (SUBSTR (s.Day11, 0, 4)) = "FRLO".
THEN
pp.startpp + 10
A SUPERIOR TIME (SUBSTR (s.Day12, 0, 4)) = "FRLO".
THEN
pp.startpp + 11
A SUPERIOR TIME (SUBSTR (s.Day13, 0, 4)) = "FRLO".
THEN
pp.startpp + 12
A SUPERIOR TIME (SUBSTR (s.Day14, 0, 4)) = "FRLO".
THEN
pp.startpp + 13
END
StartDate,
StartTime, NULL,
Time NULL terminator,
8 hours,
0 minutes
Time S
JOIN THE
payperiods pp
ON pp.periodid = s.periodid
WHERE SUPERIOR (SUBSTR (s.Day1, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day2, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day3, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day4, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day5, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day6, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day7, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day8, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day9, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day10, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day11, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day12, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day13, 0, 4)) = "FRLO".
OR SUPERIOR (SUBSTR (s.Day14, 0, 4)) = "FRLO";
----------------------------------------------------------------------------------------------
OUTPUT CURRENT
EMPID STARTDATE, STARTTIME ENDTIME HOURS MINUTES
753738, 25/03/2013, 8, 0
753740, 25/03/2013, 8, 0
753748, 25/03/2013, 8, 0
DESIREE OUTPUT
EMPID STARTDATE, STARTTIME ENDTIME HOURS MINUTES
753738, 25/03/2013, 8, 0
753740, 25/03/2013, 8, 0
753748, 25/03/2013, 8, 0
753738, 26/03/2013, 8, 0
753740, 26/03/2013, 8, 0
753740, 28/03/2013, 8, 0
753748, on 01/01/2013, 8, 0
753738, on 03/04/2013, 8, 0
753748, on 03/04/2013, 8, 0
-----------------------------------------------------------------------------------------------
CREATE THE TABLE PROGRAMS
(
SCHEDULEID NUMBER (12) NOT NULL,
EMPID NUMBER (12) NOT NULL,
PERIODID VARCHAR2 (6 BYTE) NOT NULL,
AREAID NUMBER (12) NOT NULL,
DAY1 VARCHAR2 (50 BYTE),
DAY 2 VARCHAR2 (50 BYTE).
DAY 3 VARCHAR2 (50 BYTE).
DAY4 VARCHAR2 (50 BYTE),
DAY5 VARCHAR2 (50 BYTE),
DAY6 VARCHAR2 (50 BYTE),
DAY 7 VARCHAR2 (50 BYTE).
JOUR8 VARCHAR2 (50 BYTE),
DAY9 VARCHAR2 (50 BYTE),
DAY10 VARCHAR2 (50 BYTE),
DAY 11 VARCHAR2 (50 BYTE).
DAY12 VARCHAR2 (50 BYTE),
J13 VARCHAR2 (50 BYTE),
DAY14 VARCHAR2 (50 BYTE),
NOPTIND1 INTEGER DEFAULT 0,
NOPTIND2 INTEGER DEFAULT 0,
NOPTIND3 INTEGER DEFAULT 0,
NOPTIND4 INTEGER DEFAULT 0,
NOPTIND5 INTEGER DEFAULT 0,
NOPTIND6 INTEGER DEFAULT 0,
NOPTIND7 INTEGER DEFAULT 0,
NOPTIND8 INTEGER DEFAULT 0,
NOPTIND9 INTEGER DEFAULT 0,
NOPTIND10 INTEGER DEFAULT 0,
NOPTIND11 INTEGER DEFAULT 0,
NOPTIND12 INTEGER DEFAULT 0,
NOPTIND13 INTEGER DEFAULT 0,
NOPTIND14 INTEGER DEFAULT 0
);
CREATE TABLE PAYPERIODS
(
PERIODID VARCHAR2 (6 BYTE) NOT NULL,
DATE OF STARTPP,
DATE OF ENDPP
);
Insert in CALENDARS
(SCHEDULEID, EMPID, PERIODID, DAY1, AREAID
DAY 2, DAY 3, DAY 4, DAY5 DAY6.
DAY7 JOUR8, DAY9, DAY10, DAY 11,.
J13, DAY14 DAY12, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693744, 753738, '082013' 2167, 'X')
"FRLO < 1530 > ', ' < 1530 FRLO > ', '1530', '1530', '1530',
'X', 'X', '1530', '1530', 'FRLO ',.
"1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
(0, 0);
Insert in CALENDARS
(SCHEDULEID, EMPID, PERIODID, DAY1, AREAID
DAY 2, DAY 3, DAY 4, DAY5 DAY6.
DAY7 JOUR8, DAY9, DAY10, DAY 11,.
J13, DAY14 DAY12, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693745, 753740, '082013' 2167, 'X')
"FRLO < 1530 > ', ' < 1530 FRLO > ', '1530', 'FRLO', '1530',
'X', 'X', '1530', '1530', ' 1530',
"1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
(0, 0);
Insert in CALENDARS
(SCHEDULEID, EMPID, PERIODID, DAY1, AREAID
DAY 2, DAY 3, DAY 4, DAY5 DAY6.
DAY7 JOUR8, DAY9, DAY10, DAY 11,.
J13, DAY14 DAY12, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693746, 753748, '082013' 2167, 'X')
"FRLO < 1530 > ', '1530', '1530', '1530', '1530',.
'X', 'X', ' FRLO < 1530 > ', '1530', 'FRLO ',.
"1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
(0, 0);
COMMIT;
Insert into PAYPERIODS
(PERIODID, STARTPP)
Values
(TO_DATE '082013', (MARCH 24, 2013 00:00:00 "," MM/DD/YYYY HH24:MI:SS'));))
COMMIT;Hello
I think you want:
SELECT s.empid, pp.startpp, startdate, NULL starttime, NULL endtime, 8 hours, 0 minutes FROM schedules s JOIN payperiods pp ON pp.periodid = s.periodid WHERE UPPER (SUBSTR (s.Day1, 0, 4)) = 'FRLO' UNION SELECT s.empid, pp.startpp + 1, startdate, NULL starttime, NULL endtime, 8 hours, 0 minutes FROM schedules s JOIN payperiods pp ON pp.periodid = s.periodid WHERE UPPER (SUBSTR (s.Day2, 0, 4)) = 'FRLO' --ETC.
Kind regards
Peter
-
I am trying to write the SQL for a single recordset.
I have a table with all the info from the standard article and an item_colorID.
I have a table with 2 columns, item_colorID and color_ID color_lookup
I have a table with 2 columns, color_ID colors and color
I want to join the tables and filter it so that a repeat region shows dynamic data by the name of article, thumb, description, price
and also a dynamic list/menu populated by color
filtered so that each element is in the list/menu only available element colors.
I have tried different variations of this sql
SELECT * items INNER JOIN color_lookup ON color_lookup.item_colorID = items.item_colorID INNER JOIN colors ON colors.color_ID = color_lookup.color_ID WHERE items.itemCatID = 3 ORDER BY items.itemName
but the list/menu shows each color choice, multiplied by the number of items in this color
That is to say white will show 80 + times.
Thanks for your help,
Jim balthrop
Hi JB, I think I understand the situation, but of course, I'm not familiar with the interface of the cart software you are using. It seems that you will not be able to use the choice "research from the recordset" because the color is a different Recordset. You can't really understand the color in the main recordset because it would cause the main repeating region show the item once for each available color, which is not what you want.
I also see that the drop-down color is in its own form. If you have placed this process in the main form, would be the behavior recoginize it and treat it differently? In other words, the cart accepts entry options outside the main form element it uses:
I don't know that the shopping cart software contains other methods to add to the cart you can be forced to use.
What shopping cart software are you helping? They have a forum which you could get more targeted assistance?
Maybe you are looking for
-
TBird renames my old again 2nd profile ProfileName?
I added that a new account my e-mail account existing to the new name of e-mail messaging TBird and renamed TBird. Now I have 2 different e-mail accounts with the same name when I opened TBIrd. How can I fix? Thank you, squibt
-
switch to another page of a site web game without my mouse clicking
When using some web sites have several pages Firefox goes from page I am on another page in the history, when I click on any button of the original page.Like Expedia.com , I learned from the information on the flights, then when I clicked the button
-
When firefox will be available for the Sony ericsson Experia x10i
Hi, I have a Sony ericsson Experia x10i smartphone. I can't install firefox is a browser because it has RAM toolittle.When Firefox will assign a browser for this phone?
-
Hello I have a Satellite Pro A10 and bought an internal pci wireless adapter. The following information is displayed on my card: Askey WLL3070-D4 (MOW)Atheros AR5BRB-43 I installed the card, attached to the ariel and turned on the laptop... the switc
-
I see a file, when I play the sound comes on but no picture any suggestions thanks
I downloaded a dvd of my home movies that I can see the files, but some play that for 29 seconds and one that says it's a little over an hour just plays the sound, even if I see the picture of him on the record at the beginning.