need help for a conditional query
guys this is just. as an extension of this post that Frank was helping me. IM reposting because my needs change slightly and im having a hell of a time trying to change the query.Here are the previous post.
need help with query can find data back please help.
CREATE TABLE "FGL"
(
"FGL_GRNT_CODE" VARCHAR2(60),
"FGL_FUND_CODE" VARCHAR2(60),
"FGL_ACCT_CODE" VARCHAR2(60),
"FGL_ORGN_CODE" VARCHAR2(60),
"FGL_PROG_CODE" VARCHAR2(60),
"FGL_GRNT_YEAR" VARCHAR2(60),
"FGL_PERIOD" VARCHAR2(60),
"FGL_BUDGET" VARCHAR2(60)
)
dataInsert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','00','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','1','0');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','11','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7200','4730','02','10','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('360055','360055','7600','4730','02','10','1','400');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7600','4730','02','10','14','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','14','200');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','10','2','100');
Insert into FGL (FGL_GRNT_CODE,FGL_FUND_CODE,FGL_ACCT_CODE,FGL_ORGN_CODE,FGL_PROG_CODE,FGL_GRNT_YEAR,FGL_PERIOD,FGL_BUDGET) values ('240055','240055','7240','4730','02','11','2','600');
I need to find the year of greater subsidy for the granting by a period setting.Once I found the great year, I need to check the value of the period 14 this grant for the previous year and add it to the amount of the budget for this grant. However if there is an entry in the biggest year for period 00 so I need to ignore the period 14 of the previous year and the current calculation period + (current period - more great year 00)
hope that makes sense, so in other words, with the new data above. If I asking me a second period of the grant year 11. I'd end up with $800
because the greatest year is 11 it contains one point 0 with $ 400, so my total should be
amount of period $2,600
period $0 400 - period $2 600 = $200
600 + 200 = $800
If I have question period 1 grant 360055 I'd end up just with 800 grnt year 10.
I tried to edit this query you have provided me with no luck. I tried for several embarrassed day but I'm saying I can just do what im trying to do.
can you please help me.
Here's the query provided by frank kulash who graciously put it together for me.
WITH got_greatest_year AS
(
SELECT fgl.* -- or whatever columns are needed
, MAX ( CASE
WHEN fgl_period = :given_period
THEN fgl_grnt_year
END
) OVER () AS greatest_year
FROM fgl
)
SELECT SUM (fgl_budget) AS total_budget -- or SELECT *
FROM got_greatest_year
WHERE ( fgl_grnt_year = greatest_year
AND fgl_period = :given_period
)
OR ( fgl_grnt_year = greatest_year - 1
AND fgl_period = 14
)
;
Miguel
Hi, Miguel.
You are waying that when larger year who has: given_period also a period = '00' (or '0', or whatever it is you want to use), then you want to double the budget of the given_period (subtract the '00' budget and do not count '14' year pevious)? If so, add another condition to the CASE statement that decides what you've summarized:
WITH got_greatest_year AS
(
SELECT TO_NUMBER (fgl_grnt_year) AS grnt_year
, fgl_period
, TO_NUMBER (fgl_budget) AS budget
, MAX ( CASE
WHEN fgl_period = :given_period
THEN TO_NUMBER (fgl_grnt_year)
END
) OVER () AS greatest_year
FROM fgl
)
, got_cnt_00 AS
(
SELECT grnt_year
, fgl_period
, budget
, greatest_year
, COUNT ( CASE
WHEN grnt_year = greatest_year
AND fgl_period = '00'
THEN 1
END
) OVER () AS cnt_00
FROM got_greatest_year
)
SELECT SUM ( CASE
WHEN grnt_year = greatest_year -- New
AND fgl_period = :given_period -- New
AND cnt_00 > 0 THEN budget * 2 -- New
WHEN grnt_year = greatest_year
AND fgl_period = :given_period THEN budget
WHEN grnt_year = greatest_year
AND fgl_period = '00' THEN -budget
WHEN grnt_year = greatest_year - 1
AND fgl_period = '14'
AND cnt_00 = 0 THEN budget
END
) AS total_budget
FROM got_cnt_00
;
You will notice it is the same as the previous query, I posted, with the exception of 3 lines marked 'new '.
Tags: Database
Similar Questions
-
Hi, I'm a little stuck on getting the results of a join query. Let's say I have three tables that make up one of many to go from left to right:
Project-> work-> work
Each task can have many tasks. Each task in a job can be repeated by several users, each with a different assigned_name. The tasks of a job have a value of sequence (seq), so if the same task is repeated for a job, the seq will be different.
I need to get the assigned_name of the last run of the task for each job. Here is the ddl:
Now, if I run a queryCREATE TABLE project ( id NUMBER PRIMARY KEY, name VARCHAR2(20)); INSERT INTO project (id, name) VALUES (1, 'Test Project 1'); INSERT INTO project (id, name) VALUES (2, 'Test Project 2'); CREATE TABLE job ( id NUMBER PRIMARY KEY, project_id NUMBER, name VARCHAR2(20), CONSTRAINT fk_project FOREIGN KEY (project_id) REFERENCES project(id)); INSERT INTO job (id, project_id, name) VALUES (11, 1, 'Test Job 1-11'); INSERT INTO job (id, project_id, name) VALUES (12, 1, 'Test Job 1-12'); INSERT INTO job (id, project_id, name) VALUES (13, 2, 'Test Job 2-13'); INSERT INTO job (id, project_id, name) VALUES (14, 2, 'Test Job 2-14'); INSERT INTO job (id, project_id, name) VALUES (15, 2, 'Test Job 2-15'); CREATE TABLE task ( id NUMBER, seq NUMBER, job_id NUMBER, name VARCHAR2(20), assigned_name VARCHAR2(20), CONSTRAINT pk_task PRIMARY KEY (id, seq), CONSTRAINT fk_job FOREIGN KEY (job_id) REFERENCES job(id)); INSERT INTO task (id, seq, job_id, name, assigned_name) VALUES (101, 1, 11, 'Test Task 1-11-101', 'Bob'); INSERT INTO task (id, seq, job_id, name, assigned_name) VALUES (102, 2, 11, 'Test Task 1-11-102', 'Jack'); INSERT INTO task (id, seq, job_id, name, assigned_name) VALUES (103, 1, 12, 'Test Task 1-12-103', 'Mary'); INSERT INTO task (id, seq, job_id, name, assigned_name) VALUES (104, 2, 12, 'Test Task 1-12-104', 'Phil'); INSERT INTO task (id, seq, job_id, name, assigned_name) VALUES (104, 3, 12, 'Test Task 1-12-104', 'Bill'); INSERT INTO task (id, seq, job_id, name, assigned_name) VALUES (105, 4, 12, 'Test Task 1-12-105', 'Ed'); INSERT INTO task (id, seq, job_id, name, assigned_name) VALUES (105, 5, 12, 'Test Task 1-12-105', 'Tom'); INSERT INTO task (id, seq, job_id, name, assigned_name) VALUES (105, 6, 12, 'Test Task 1-12-105', 'John'); COMMIT;
Then, I get:SELECT p.name project_name, j.name job_name, t.name task_name, t.seq, t.assigned_name FROM project p, job j, task t WHERE p.id = j.project_id AND j.id = t.job_id AND t.job_id = 12 ORDER BY 1,2,3,4;
While I would like to:PROJECT_NAME JOB_NAME TASK_NAME SEQ ASSIGNED_NAME -------------------- -------------------- -------------------- ---------- -------------- Test Project 1 Test Job 1-12 Test Task 1-12-103 1 Mary Test Project 1 Test Job 1-12 Test Task 1-12-104 2 Phil Test Project 1 Test Job 1-12 Test Task 1-12-104 3 Bill Test Project 1 Test Job 1-12 Test Task 1-12-105 4 Ed Test Project 1 Test Job 1-12 Test Task 1-12-105 5 Tom Test Project 1 Test Job 1-12 Test Task 1-12-105 6 John
i.e.PROJECT_NAME JOB_NAME TASK_NAME SEQ ASSIGNED_NAME -------------------- -------------------- -------------------- ---------- -------------------- Test Project 1 Test Job 1-12 Test Task 1-12-103 1 Mary Test Project 1 Test Job 1-12 Test Task 1-12-104 3 Bill Test Project 1 Test Job 1-12 Test Task 1-12-105 6 John
For each combination of project.id/job.id/task.id, I need to get the record with the highest task.seq
Any ideas? I'm puzzled.
Thank you.
I'm on 10gSQL> SELECT p.name project_name, j.name job_name, t.name task_name, 2 max(t.seq) seq, 3 max(t.assigned_name) keep (dense_rank first order by t.seq desc) assigned_name 4 FROM project p, job j, task t 5 WHERE p.id = j.project_id 6 AND j.id = t.job_id 7 AND t.job_id = 12 8 GROUP BY p.name, j.name, t.name 9 ORDER BY 1,2,3,4 10 / PROJECT_NAME JOB_NAME TASK_NAME SEQ ASSIGNED_NAME -------------------- -------------------- -------------------- ---------- -------------------- Test Project 1 Test Job 1-12 Test Task 1-12-103 1 Mary Test Project 1 Test Job 1-12 Test Task 1-12-104 3 Bill Test Project 1 Test Job 1-12 Test Task 1-12-105 6 John SQL>
SY.
-
I need help with a simple query in an ORACLE database. I tried a lot of things that I found on the internet, but none of them worked for me.
The following query retrieves four lines:
SELECT sampled_date AS VALUE1, VALUE2 AS result, 0 as value3
Of asw_lab
WHERE template_result = 'A' AND analysis = 'B' AND ROWNUM < 5
ORDER BY sampled_date DESC;
I would like to calculate a moving average of the last four values with the date of the sample of the last line.
For example, I have this result for the query above:
Value1 value2 value3
01/04/14-16:00 1 0
01/04/14 15:00 2 0
01/04/14 14:00 3 0
01/04/14 13:00 4 0
I want to extract the below my average/query calculation result:
Value1 value2 value3
01/04/14-16:00 2.5 0
Can you help me create a request to that effect?
Thank you
Maybe it's
Select max (VALUE1) VALUE1, VALUE2 avg (VALUE2), avg (VALUE3) value3
Of
(
SELECT sampled_date AS VALUE1, VALUE2 AS result, 0 as value3
Of asw_lab
WHERE template_result = 'A' AND analysis = 'B' AND ROWNUM<>
)
-
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.
-
Need help for optical safety circuit.
I buy these parts and prototype with real components, but since I multisim, I thought it would be nice to create the circuit and maybe work through issues I can practically.
I need a circuit that takes 120 VCA, generates 5 VDC and 1.5Vdc power of optical transmitter and receiver. I actually use a data port because he has great range and is pretty cheap. Rather than send the binary code well I just send a light stead that is broken or not broken through doors and windows in my house. Then the receiver sees this as an entry and order a relay.
I tried several voltage regulators that come with multisim, but I get an error of execution of my circuit. Really I can't the 120 VAC to power levels necessary for the functioning of the optics.
Otherwise I might want to run on a system 120Vdc with battery backup, so throw a 120Vdc up to 20 v DC switching power supply - but I have not found a SMP in the library which takes 120 as input and as output 20.
Basic plan: 120VAC source-> transform to 24Vac-> Full bridge rectifier to ~ 20 v DC-> voltage capacitor filter on the input of two voltage regulators (1 to 5 VDC, 1 to 1.5Vdc) - then circuit since the two power supply of the transmitter and the receiver.
I just need help for 5V and 1.5V, from there, I know that the real world circuit will work component tests already carried out. Thanks for reading.
I didn't Multism so I can't advise you on the compatible models. I ran the model on semiconductors with slight modifications of format on my SPICE simulator based on Berkeley Spice 3f5. I had to change the format of model resistance semiconductors appeal but has not changed any values.
The output of your power supply circuit 3 (with 5 V, not the 1.5 V regulator regulator) was 4.99995 V.
There are a few messages about changing templates published for compatibility Multisim woth. You can search those to see if there are any suggestions on what you'll need to fix in the model.
Lynn
-
I need help for the upgrade of my current system.
I need help for the upgrade of my current system.
I have SBS 2008 with (Exch 2007, SQL 2005, Sharepoint, backupexec 2010 for sbs) licenses.
I want to make the larger environment using the following:
(1) apply Virtualization
(2) apply to the failover process (clustering)
"(3) the environment must support adding server terminal server, ERP server, exchange server, domain controller, backup manager.
Storage 4) that supports Raid (1 and 5)
UTM excellent 6) that supports (SSL VPN, VPN Global)
suitable backup solution 7)
(8) good antivirus for clients
my questions:
(1) can you provide me with a good design for this environment
(2) should I choose what operating system:
Microsoft datacenter or company
I know datacenter provide us the unlimited VM but needs per processor license
so if I have two Grouped servers I want to buy 4 licenses
and just 4 VMs per company license... to say that we have two servers and maintain 8 vms so wat happened if 1 goes down... How can I migrate the 4 virtual machines on the server failed to another server group... ? should I buy enterprise license?
(3) if I get the SAN storage for data... How can I save this storage... should I get another SAN?
(4) how can I upgrade SBS stad single server (windows standrad) without losing the licenses as Exch 2007, SQL 2005, sharepoint.is it a must to buy an edition full std server or there is a way to upgrade (license wise, I mean)?
(5) what about win2k8 license for VM:
lets say we have physical that has windows license so that enough to have windows for VM or should I buy windows for VM licenses?
(6) can I use backExec license for SBS with windows 2008 standard
(7) who better to virtualization AMD or INTEL
(8) hyper V or VMware?
(9) what of Microsoft data protection Manager... is this good?
(10) what virtual machine manager? What are the benefites keys
Thanks in advance
Hello AnasAI,
You can find the Server forums on TechNet support, please create a new post at the following link:
http://social.technet.Microsoft.com/forums/en/category/WindowsServer/
-
I need help for activation of the real administrator account.
I have a problem with Adobe reader 9 standard, Adobe customer service asked the unhide real administrator account before you can continue to help me.
I need help for that.
http://www.Vistax64.com/tutorials/67567-administrator-account.html
Read the above info.
See you soon. Mick Murphy - Microsoft partner
-
I need help for my reader to USB drive on my windows 10 ACER?
I need help for my reader to USB stick on my chrome windows 10 plug ins acer. Can you help me?
What Adobe application that you use?
This is the Adobe Media Encoder forum, and you did not mention anything on this subject. If you can let us know what Adobe application, you need help, we can help you make the right forum.
Thank you
Regalo
-
Hello, I need help for cancel the payment on my adobe account.
Hello, I need help for cancel the payment on my adobe account. I'm from Peru, Im paying a monthly fee as a student. Help, please...
-
Hello, need help for Adobe Reader DC playing animation files that are specified in the pdf output by script Latex Beamer. My Adobe Reader DC refuse to open any format that I gave him. Thank you very much
Hey ihorl18351266,
Please note that you can open PDF files using only the CD player. Any other format will not be supported by the software.
Kind regards
Ana Maria
-
Need help for query flat_file type clobdata oracle table data.
Hi Sir,
I need help to query oracle table flat file data having given clob type.
COLUMN FOR CHAR_DATA FLAT_FILEOracle Version: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product PL/SQL Release 10.2.0.1.0 - Production "CORE 10.2.0.1.0 Production" TNS for 32-bit Windows: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production Source table CREATE TABLE order_details ( QUEUE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, LINE_SEQNUM NUMBER(10,0) NOT NULL ENABLE, CHAR_DATA CLOB, OPTIMISTIC_LOCK_KEY NUMBER(20,0) )
EXPECTED RESULTS:EU,6067AT,AT10,000000402004,NexiumGERDManagementProject,Z435,,ZZ29,NIS-GOLD,AT EU,6067AT,AT10,000000402038,NIS-OEU-ARI-2007/1,Z450,,ZZ29,NIS-OEU-ARI-2007/1,AT EU,6067AT,AT10,000000402039,SymbicortNISinCOPD,Z450,,ZZ29,NIS-REU-DUM-2007/1,AT EU,6067AT,AT10,000000402040,D1443L00044SeroquelXRRuby,Z450,,ZZ29,D1443L00044,AT EU,6067AT,AT10,000000402041,NIS-GEU-DUM-2008/1,Z450,,ZZ29,NIS-GEU-DUM-2008/1,AT EU,6067AT,AT10,000000402042,SonstigeAktivitätenLCM,Z450,,ZZ29,.,AT EU,6067AT,AT10,000000402134,D1680L00002Saxagliptin,Z450,,ZZ29,D1680L00002,AT EU,6067AT,AT10,000000402199,SeroquelWaveNIS,Z450,,ZZ29,NIS-NEU-DUM-2009/1,AT EU,6067AT,AT10,000000402313,SeroquelExtra(D1443L00082),Z450,,ZZ29,D1443L00082,AT EU,6067AT,AT10,000000402517,AtlanticD5130L00006(AZD6140),Z450,,ZZ29,D5130L00006,AT EU,6067AT,AT10,000000554494,ArimidexSt.Gallen(13+2),Z142,,ZZ09,,AT EU,6067AT,AT10,000000554495,ArimidexASCO(5delegates),Z142,,ZZ09,,AT EU,6067AT,AT10,000000554496,ArimidexSanAntonio6delegates,Z142,,ZZ09,,AT EU,6067AT,AT10,000000554497,ArimidexBreastCancerSummit(13+2),Z130,,ZZ09,,AT EU,6067AT,AT10,000000554498,ArimidexEIH(15delegates),Z130,,ZZ09,,AT EU,6067AT,AT10,000000554499,ArimidexNIFA(200delegates),Z135,,ZZ09,,AT EU,6067AT,AT10,000000554500,ArimidexNIFAworkshops(8x25),Z135,,ZZ09,,AT EU,6067AT,AT10,000000554501,ArimidexPraktischeGyn.Fortbildung,Z147,,ZZ09,,AT EU,6067AT,AT10,000000554502,ArimidexAGO,Z147,,ZZ09,,AT EU,6067AT,AT10,000000554503,ArimidexHämato/OnkologieKongress,Z147,,ZZ09,,AT EU,6067AT,AT10,000000554504,ARIMIDEXGYNäKOLOGENKONGRESS,Z147,,ZZ09,,AT EU,6067AT,AT10,000000554505,ArimidexChirurgenkongress,Z147,,ZZ09,,AT
AFFIRM_CODE COMPANY_CODE INTERNAL_ORDER_CODE INTERNAL_ORDER_DESC ENIGMA_ACTIVITY SUB_ACTIVITY_CODE IN_AFF_IND ORDER_TYPE EXTERNAL_ORDER COUNTRY EU 6067AT AT10 000000402004 NEXIUMGERDMANAGEMENTPROJECT Z435 NULL ZZ29 NIS-GOLD AT EU 6068AT AT11 000000402005 NEXIUMGERDMANAGEMENTPROJECT Z435 NULL ZZ29 NIS-GOLD AT
Sorry, my bad. Without database at hand, I'll try 'baby steps' (borrowed from Frank) so you don't confuse it with errors that I might add (happens far too often already, but at least you won't "swallow" as forum members think is one of the main goals of this fighter - help her learn - providing not only the proverbial fish.)
Search the Forum - your problem is one of its best sellers. Watching {message identifier: = 10694602} ("split string into" was the key word used in research) you can try something asselect table_row, level clob_row, regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) the_line from (select to_char(queue_seqnum)||':'||to_char(line_seqnum) table_row, char_data from order_details ) connect by regexp_substr(char_data,'[^' || chr(13) || chr(10) || ']+',1,level) is not null and prior char_data = char_data and prior table_row = table_row and prior sys_guid() is not null
to get all the s the_lineall CLOB and after that the use of the example even to get your columns of each the_line.
Concerning
Etbin
Edited by: Etbin on 3.2.2013 09:01
.. .but I m connected to do things according to the instructions, I can't do something.
Used to happen to me too and I did as told to the but only after explaining any disadvantages, I was aware of in time. The last sentence is usually: "O.K. now be just and Don't come back with that kind of thing when it turns out that this isn't the right thing."
rp0428 post - something to remember. -
Hi gurus
need help with this query,
I want to display the records in the table emp
I want just the recordsSQL> Select Deptno,sal,sal/SUMSAL Percent,rn 2 From ( Select emp.*,Sum(Sal) Over() "SUMSAL",Row_number() Over(Order by sal Desc) rn 3 From emp 4 ) 5 / EMPNO DEPTNO SAL PERCENT RN --------- ---------- ---------- ---------- ---------- 7839 10 5000 .172265289 1 7902 20 3000 .103359173 2 7788 20 3000 .103359173 3 7566 20 2975 .102497847 4 7698 30 2850 .098191214 5 7782 10 2450 .084409991 6 7499 30 1600 .055124892 7 7844 30 1500 .051679587 8 7934 10 1300 .044788975 9 7521 30 1250 .043066322 10 7654 30 1250 .043066322 11 7876 20 1100 .037898363 12 7900 30 950 .032730405 13 7369 20 800 .027562446 14 14 rows selected.
Thank youEMPNO DEPTNO SAL PERCENT RN ---------- ---------- ---------- ---------- ---------- 7839 10 5000 .172265289 1 7902 20 3000 .103359173 2 7788 20 3000 .103359173 3 7566 20 2975 .102497847 4 7698 30 2850 .098191214 5 with sum (Percent) of remaing records..... Others .420327304
Published by: SeenuGuddu on February 27, 2011 03:39with a as ( Select Empno, Deptno ,sal, sal/SUMSAL Percent, case when rn<=5 then rn else null end rnm From (Select emp.*, Sum(Sal) Over() "SUMSAL", Row_number() Over(Order by sal Desc) rn From emp) ) select case when max(rnm) is not null then to_char(max(empno)) else 'Others:' end empno, case when max(rnm) is not null then max(deptno) else null end deptno, case when max(rnm) is not null then max(sal) else null end sal, to_char(sum(percent), '90.99') percent, max(rnm) rn from a group by rnm order by rnm
EMPNO DEPTNO SAL PERCENT RN ---------------------------------------- ---------------------- ---------------------- ------- ---------------------- 7839 10 5000 0.17 1 7902 20 3000 0.10 2 7788 20 3000 0.10 3 7566 20 2975 0.10 4 7698 30 2850 0.10 5 Others: 0.42 6 rows selected
-
I 3050 points in expertzone how rendeem that points? Please tell
Hi Junaid,
Thanks for posting your query in the Microsoft Community Forums!
The Microsoft Community doesn't have a real influence on or for the Microsoft ExpertZone so you will need to contact them.
Microsoft ExpertZone
http://expertzone.Microsoft.com/See the FAQ and contact us at the bottom of the home page.
There is also a Microsoft ExpertZone on Facebook.
Microsoft ExpertZone - Facebook
http://www.Facebook.com/expertzoneI hope this helps.
Let us know if you encounter problems under windows in the future. We will be happy to help you.
-
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.
-
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 did
I 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:24Thanks 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
Maybe you are looking for
-
Need new battery for Satellite L10-142
I need to buy a new battery for my L10-142.The part no is PA3420U-1BRS. I see that the Web of Toshiba site classes now as 'ABANDONED '! Any ideas/recommendations for what is the best place to buy a new battery of?Thank you very much.
-
COMO HAGO PARA PODER VER ARCHVOS PPT
COMO HAGO PARA PODER VER ARCHVOS PPT
-
OK, so I can't for the life of me find an email, online chat, phone number for General customer service. I ordered my mini 311 and it is said he shipped on Monday 5 and won't be here until the 12th, yet I paid for 2 day shipping. Anyone has any ideas
-
Service pack 2 80092004 Vista error codeRun the stand-alone update packageLoad service pack 2run stand-alone service pack 2error code not found crypt_E_ (0 x 80092004)could not open log file
-
Update a problem during the installation!
Update a problem during the installation!