Query to achieve the desired result
Hi all
Am happy to post my first question in this Forum. Please guide me to get the output as shown below using oracle - sql.
C1 c2 c3 c4 OF THE amt
a d c b 50 exp
a, b, c and d nonmed 60
The data above should be modified as shown below.
C1 C2 C3 C4 OF THE amt OF THE amt
a d c 50-60 nonmed b exp
How can achieve us this, Pls Help.
Thank you
Harish
PIVOT is the way to go.
But just for fun, while relying on the input you provided, there may be another approach like that... (questionable solution because of the ambiguous order by clause)
-------
WITH dataset (c1,c2, c3, c4,DES,amt) AS (SELECT 'a', 'b', 'c', 'd', 'exp', '50' FROM DUAL UNION ALL SELECT 'a', 'b', 'c', 'd', 'nonmed', '60' FROM DUAL) select * from (SELECT c1,c2,c3,c4,des,amt,lead(des) over(partition by 1,2,3,4 order by null) col3,lead(amt) over(partition by 1,2,3,4 order by null) col4 FROM dataset) where col3 is not null and col4 is not null;
Output:
C1 | C2 | C3 | C4 | THE | AMT | COL3 | COL4 |
one | b | c | d | exp | 50 | nonmed | 60 |
See you soon,.
Manik.
Tags: Database
Similar Questions
-
Query not showing the desired result
Hi all
DB:-10.2.0.3
I use the backuppice, which is located between the dates specified by the query after query to extarct. I am really surprised, why it is not giving me the expected results.
select handle, to_char(start_time, 'dd-mon-yy hh24:mi:ss') "start_time" , to_char(completion_time, ' dd-mon-yy hh24:mi:ss') "end_time" from v$backup_piece where to_char(start_time,'dd-mon-yy hh24:mi:ss') >'27-oct-10 23:00:00' and to_char(completion_time,'dd-mon-yy hh24:mi:ss')<'28-oct-10 04:20:53' Results truncated, just to fit in this window. 23:02:25 /data/oracle/LNEVRPP1/backup/database/c-465769364-20100927-0c 27-sep-10 23:02:39 27-sep-10 23:02:40 /data/oracle/LNEVRPP1/backup/database/LNEVRPP1_ctl_l1_t730854174_s32554_p1.rmn 27-sep-10 23:02:58 27-sep-10 23:02:59 /data/oracle/LNEVRPP1/backup/database/c-465769364-20100927-0d 27-sep-10 23:03:02 27-sep-10 23:03:02 /data/oracle/LNEVRPP1/backup/database/LNEVRPP1_arc_l1_t730854220_s32556_p1.rmn 27-sep-10 23:03:41 27-sep-10 23:03:44 /data/oracle/LNEVRPP1/backup/database/c-465769364-20100927-0e 27-sep-10 23:03:51 27-sep-10 23:03:51 /data/oracle/LNEVRPP1/backup/database/LNEVRPP1_dbf_l0_t733532449_s33531_p1.rmn 27-oct-10 23:00:50 27-oct-10 23:36:00 /data/oracle/LNEVRPP1/backup/database/LNEVRPP1_dbf_l0_t733534566_s33532_p1.rmn 27-oct-10 23:36:07 27-oct-10 23:48:38 HANDLE start_time end_time ------------------------------------------------------------------------------------- --------------------------- ----------- ----------------- /data/oracle/LNEVRPP1/backup/arc2adsm/LNEVRPP1_arc_l0_t733536053_s33534_p1.rmn 28-oct-10 00:00:54 28-oct-10 00:01:13 /data/oracle/LNEVRPP1/backup/database/c-465769364-20101028-00 28-oct-10 00:01:22 28-oct-10 00:01:23 /data/oracle/LNEVRPP1/backup/database/LNEVRPP1_dbf_l0_t733535322_s33533_p1.rmn 27-oct-10 23:48:43 28-oct-10 00:20:06 /data/oracle/LNEVRPP1/backup/database/LNEVRPP1_dbf_l0_t733537209_s33536_p1.rmn 28-oct-10 00:20:10 28-oct-10 00:33:44 /data/oracle/LNEVRPP1/backup/database/c-465769364-20101028-01 28-oct-10 00:33:47 28-oct-10 00:33:48 /data/oracle/LNEVRPP1/backup/database/LNEVRPP1_ctl_l0_t733538041_s33538_p1.rmn 28-oct-10 00:34:04 28-oct-10 00:34:04 /data/oracle/LNEVRPP1/backup/database/c-465769364-20101028-02 28-oct-10 00:34:06 28-oct-10 00:34:07
Hello
Try:
handle Select to_char (start_time, 'dd-mon-yy hh24:mi:ss') 'start_time', to_char (completion_time, 'dd-mon-yy hh24:mi:ss'), 'end_time '.
v $ element_sauvegarde
where start_time > to_date (27 October 10 23:00 "," dd-mon-yy hh24:mi:ss'")
and completion_time< to_date="" ('28-oct-10="" 23:00:00','dd-mon-yy="">
/Kind regards
Tycho
-
SQL query to get the desired result
I have the array with the following values
Account Functional currency Billing currency Amount Header 5 101 USD USD 10 h 00 101 USD CAD 12 h 00 102 JPY USD 9 h 00 102 JPY CAD 3.00 102 JPY SGD 2.00 If the account has one different inv_currencypar that the functional currency and then
I have to summarize the amount in this account by viewing the billing currency
If the account has more than one other inv_currencypar that the functional currency and then
I have to summarize the amount in this account showing the functional currency as the currency of invoicing
I need output like this:
Account
Functional currency Billing currency Total amount Header 5 101 USD CAD 10:00 pm 102 JPY JPY 2:00 pm Can we get over output in sql without writing pl/sql program?
Hello
According to your specific needs, here's a way:
SELECT account
functional_currency
CASE
WHEN 1 = COUNT (DISTINCT NULLIF (invoice_currency
functional_currency
)
)
THEN MAX (NULLIF (invoice_currency
functional_currency
)
)
Of OTHER functional_currency
END AS invoice_currency
The SUM of (amount) AS total_amount
header5
FROM table_x
GROUP BY account
functional_currency
header5
;
If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.
Is it possible to have 2 (or more) of different functional_currencies in the same account?
-
I have about 340 pages spanning more than 100 documents (for possible use with Digital Publishing Suite).
I would like to design content that will be used in a similar way to the master page content I would like to cover several documents, but be modifiable and update all pages.
Excerpts from old in GoLive (long ago) used to allow to make changes to the excerpt of master, and these changes would update all pages connected with the content has been fixed.
Is it possible in InDesign to connect the content of the document in this way? It doesn't have to be extracted. Any method or tool will do.
Thank you
Picture is worth a thousand words:
And Yes, it is one thing to InDesign, but I wanted to share the DPS Forum in case you need something specific there.
-
Why "bgp bestpath missing-as-worst med" command does not produce the desired result?
Can dear all, someone tell me why "bgp bestpath missing-as-worst med" command does not produce the desired result?
And I use GNS3 to this practice, the IOS Version: 12.4 (3)
TKS...Back to the beginning:
192.168.23.0/24 192.168.12.0/24
RA(F0/0)-(f0/0) RB (s2/0) - RC (s2/0)
[AS1] [AS2] [AS3]Configuration:
* RA *:
A #do sh run (config - router). b r b
router bgp 1
no synchronization
The log-neighbor BGP-changes
1.1.1.0 netmask 255.255.255.0
192.168.12.2 neighbor remote-2
setmed map of nearby route 192.168.12.2 out
No Auto-resumeIP route 1.1.1.0 255.255.255.0 Null0
setmed allowed 10 route map
the metric value 20* RB *:
B (config - router) #do sh run | b r b
router bgp 2
no synchronization
BGP always-compare-med
The log-neighbor BGP-changes
BGP bestpath missing-as-worst med
neighbor 192.168.12.1 distance-1
neighbour 192.168.23.3 distance-3
No Auto-resume* RC *:
C (config - router) #do sh run | b r b
router bgp 3
no synchronization
The log-neighbor BGP-changes
1.1.1.0 netmask 255.255.255.0
neighbour 192.168.23.2 distance-2
No Auto-resumeIP route 1.1.1.0 255.255.255.0 Null0
But when I checked out table RB bgp, as below:
B (config - router) #do sh ip bgp
BGP table version is 2, local router ID is 192.168.23.2
Status codes: deleted, cushioning d s, history of h, * valid, > best, i - internal.
r SIDE-failure, stale S
Source codes: i - IGP, e - EGP,? -incomplete
Network Next Hop path metrics LocPrf weight
* > 1.1.1.0/24 192.168.23.3 0 0 3 I
* 192.168.12.1 20 0 1 iThe prefix is assigned a MED of 0, but also the best path value when I use "bgp bestpath missing-as-worst med" in how to configure bgp... :-(
Please take a look at the discussion on the configuration of drugs to an eBGP neighbor:
https://supportforums.Cisco.com/thread/343397?TSTART=0
Note that BGP MED is set to 0 even if the injected BGP route from a connected route.
The first time I came across this problem sending MED was there in a picture of 5-6 years service provider. Routes were injected into BGP with the command 'network', has been validated by OSPF routes or static to null0. Involuntary consignment of drugs was mess with load balancing between 2 links of our inbound traffic from the same upstream service provider.
Also note that if a route is learned via iBGP, border router removes MED before the road to advertising for an eBGP peers (i.e. the above comments apply a when a route is injected locally into the border and then router BGP sent to an eBGP peer).
I don't know what the cause of the problem that you said in your last post. It delivers last for a long time or that it does not change after a while?
p.s. Sorry, I edited post because I said "iBGP" instead of "eBGP" at some point.
-
How to rewrite this query to get the correct results?
Friends,
DB: 9iR2
I need to get the name of the employee and the employee number that are not in the table of presence.
but this query is not the right answer.
Thank youselect e.eno,e.ename from empl e where e.eno not in (select a.eno from attendance a)
Depending on your data
SQL> create table attendance( 2 ENO VARCHAR2(5), 3 TDATE VARCHAR2(10), 4 IN_TIME VARCHAR2(6), 5 OUT_TIME VARCHAR2(6), 6 SHIFT_NO NUMBER(1)); Table created. SQL> create table empl( 2 ENO VARCHAR2(5), 3 ENAME VARCHAR2(75)); Table created. SQL> insert into empl values('11','AA'); 1 row created. SQL> insert into empl values('12','AB'); 1 row created. SQL> insert into empl values('13','AC'); 1 row created. SQL> insert into empl values('14','AD'); 1 row created. SQL> insert into empl values('15','AF'); 1 row created. SQL> insert into attendance values('11','23-3-2009','9.00','6.00',1); 1 row created. SQL> insert into attendance values('14','24-3-2009','9.00','6.00',1); 1 row created. SQL> insert into attendance values('11','25-3-2009','9.00','6.00',1); 1 row created. SQL> insert into attendance values('13','23-3-2009','9.00','6.00',1); 1 row created. SQL> insert into attendance values('15','23-3-2009','9.00','6.00',1); 1 row created. SQL> commit; Commit complete. select e.eno,e.ename from empl e where not exists(select 1 from attendance a where a.eno=e.eno); ENO ENAME 12 AB
Twinkle
-
Group query do not give the desired results
Hello
I have a requirement minimum months based on the State to find:
The following query is in error:
SELECT
b.APP_NAME,
DECODE (a.status,
'C', 'closed ',.
'O', 'open ',.
'F', 'Future',
"W", "pending."
', 'Not open') decode_status
MIN (a.period_name)
TABLE,.
table b
WHERE a.app_id = b.app_id
AND b.app_name = 'name1 '.
A.book_id = & book_id
AND a.status = 'o'
B.app_name GROUP,
DECODE (a.status,
'C', 'closed ',.
'O', 'open ',.
'F', 'Future',
"W", "pending."
', 'Not open') decode_status
for ex: in the above query if I have four records with the status 'o' and period_name ' may-12', ' Jun-12', ' Jun-12', ' Aug-12', then I need to choose 'may "".
Thank you
KiranMaybe
SELECT b.app_name, DECODE (a.status,'C','Closed','O','Open','F','Future','W','Pending','N','Not Opened') decode_status MIN(to_char(to_date(a.period_name,'Mon-RR'),'RRMM')) period_num FROM table a, table b WHERE a.app_id = b.app_id AND b.app_name = 'NAME1' AND a.book_id = :book_id AND a.status = 'O' GROUP BY b.app_name,DECODE(a.status,'C','Closed','O','Open','F','Future','W','Pending','N','Not Opened')
Concerning
Etbin
-
How to get the desired result when subsequent month is not available
WITH T1 AS (SELECT 'A' COL1, 'B' COL2, 'C' COL3, '01-Jan-2015' DT, 10 QTY FROM DUAL UNION SELECT 'A' COL1, 'B' COL2, 'C' COL3, '01-feb-2015' DT, 20 QTY FROM DUAL UNION SELECT 'A' COL1, 'B' COL2, 'C' COL3, '01-mar-2015' DT, 30 QTY FROM DUAL UNION SELECT 'A' COL1, 'B' COL2, 'C' COL3, '01-may-2015' DT, 40 QTY FROM DUAL UNION SELECT 'A1' COL1, 'B1' COL2, 'C1' COL3, '01-mar-2015' DT, 40 QTY FROM DUAL UNION SELECT 'A1' COL1, 'B1' COL2, 'C1' COL3, '01-may-2015' DT, 40 QTY FROM DUAL) SELECT * FROM t1
Current output:
COL1 COL2 COL3 DT QTY. A B C January 1, 2015 10 A B C February 1, 2015 20 A B C 01-mar-2015 30 A B C 01-may-2015 40 A1 B1 C1 01-mar-2015 40 A1 B1 C1 01-may-2015 40 Expected results
COL1 COL2 COL3 DT QTY. DT REQ_VAL A B C 01/01/2015 10 01/01/2015 20 A B C 01/02/2015 20 01/02/2015 30 A B C 01/03/2015 30 01/03/2015 0 A B C 01/05/2015 40 01/05/2015 0 A1 B1 C1 01/03/2015 40 01/03/2015 0 A1 B1 C1 01/05/2015 40 01/05/2015 0 Logic:
If we COL1, COL2, COL3 combination for A, B, C, we have the quantity for 1 January, 1 February, 1 March, 1 may, and we don't have quantity for April 1 and June 1. I need following QUANTITY value as another column. If I use the lead, I'll get the value from May 1st to March 1st, but I want to value 0 because it is after March either.
What I've tried so far:
SELECT * FROM (WITH T1 AS (SELECT 'A' COL1, 'B' COL2, 'C' COL3, '01-Jan-2015' DT, 10 QTY FROM DUAL UNION SELECT 'A' COL1, 'B' COL2, 'C' COL3, '01-feb-2015' DT, 20 QTY FROM DUAL UNION SELECT 'A' COL1, 'B' COL2, 'C' COL3, '01-mar-2015' DT, 30 QTY FROM DUAL UNION SELECT 'A' COL1, 'B' COL2, 'C' COL3, '01-may-2015' DT, 40 QTY FROM DUAL) SELECT COL1, COL2, COL3, TO_DATE (T1.DT) DT, NVL (QTY, 0) QTY, MONTHS.DT ALL_DATES, LEAD (NVL (QTY, 0), 1, 0) OVER (ORDER BY MONTHS.DT) REQ_VAL FROM T1, ( SELECT ADD_MONTHS (TO_DATE ('01-jun-2015'), LEVEL - 6) DT FROM DUAL CONNECT BY LEVEL <= 12) MONTHS WHERE MONTHS.DT = T1.DT(+)) WHERE DT ISNOTNULL;
My query works for a set of COL1, COL2, COL3, am looking how we can achieve multiple COL1, COL2, COL3 (or) otherwise better query writing.
Thanks for your suggestions in advance.
Thank you
Now, to understand your condition: your additional column must indicate the amount of the next month, or zero if it is not a record for the month. How about this?
WITH T1
AS (SELECT 'A' COL1,)
'B' COL2,
COL3 'C ',.
To_date('01-Jan-2015','dd-mon-yyyy') DT,
QTY 10
OF THE DOUBLE
UNION
SELECT 'A' COL1,
'B' COL2,
COL3 'C ',.
To_date('01-Feb-2015','dd-mon-yyyy') DT,
QTY. 20
OF THE DOUBLE
UNION
SELECT 'A' COL1,
'B' COL2,
COL3 'C ',.
To_date('01-Mar-2015','dd-mon-yyyy') DT,
QTY 30
OF THE DOUBLE
UNION
SELECT 'A' COL1,
'B' COL2,
COL3 'C ',.
To_date('01-May-2015','dd-mon-yyyy') DT,
QUANTITY 40
OF THE DOUBLE
UNION
SELECT 'A1' COL1,
COL2 "B1."
COL3 "C1"
To_date('01-Mar-2015','dd-mon-yyyy') DT,
QUANTITY 40
OF THE DOUBLE
UNION
SELECT 'A1' COL1,
COL2 "B1."
COL3 "C1"
To_date('01-May-2015','dd-mon-yyyy') DT,
QUANTITY 40
THE DOUBLE)
X.Col1, x.col2, x.col3, x.dt, x.qty, NVL(y.qty,0) SELECT req_val
THE t1 x
LEFT OUTER JOIN t1 y
ON y.col1 = x.col1
AND y.col2 = x.col2
AND y.col3 = x.col3
AND y.dt = add_months(x.dt,1)
ORDER BY 1,2,3,4
My query works for a DFU, am looking how we can achieve multiple UTD
What is a DFU?
-
Failed to get the desired result
Hi gurus
Don't know why I get the following output:
Query
SOME jobs,
COUNT (*),
COUNT (CASE job WHEN 'CLERK' THEN 1 ELSE 0 END) cnt
WCP
Working GROUP;
The query result
WORK, COUNT (*), CNT
3 3 CLERKS
4 4 SELLER
THE PRESIDENT 1 1
MANAGER 3 3
1 1 ANALYST
According to my understanding, the result should be as below:
Result must be
WORK, COUNT (*), CNT
3 3 CLERKS
SELLER 4 0
THE PRESIDENT 1 0
MANAGER 3 0
ANALYST 1 0
Thanks in advance.
Concerning
Shu
Hello
Shuumail wrote:
Hi gurus
Don't know why I get the following output:
Query
SOME jobs,
COUNT (*),
COUNT (CASE job WHEN 'CLERK' THEN 1 ELSE 0 END) cnt
WCP
Working GROUP;
The query result
WORK, COUNT (*), CNT
3 3 CLERKS
4 4 SELLER
THE PRESIDENT 1 1
MANAGER 3 3
1 1 ANALYST
According to my understanding, the result should be as below:
Result must be
WORK, COUNT (*), CNT
3 3 CLERKS
SELLER 4 0
THE PRESIDENT 1 0
MANAGER 3 0
ANALYST 1 0
Thanks in advance.
Concerning
Shu
COUNT (*) tells you how many lines there are.
COUNT (exp) tells you how many lines have a value not NULL in exp
Your CASE expression never returns null; It always returns a value of 0 or 1, but never NULL. So, if exp is never NULL, so each line has a value not NULL and if COUNT (*) and COUNTY (exp) are always the same.
-
Query and update the large result set
I do need to update 50,000 lines in the comic book. Because I can not load the set(50K) of any result in memory as I'm reading the rows per batch, 200 lines of each loop by incrementing fetchStart of the view object and then do a re - interview.
I think pointed out that time elapse for every loop slows down over time.
Here is the code snippet:
range final int = 200;
int fetchStart = 0;
fetchSize int = range;
int range = increment;
Boolean doFetch = true;
Product list = new ArrayList (range);
so that {(doFetch)
products = getProducts (fetchStart, fetchSize); view //Modifies with the fetchStart and the re object - interview.
fetchStart = index + 1;
increment = increment + range;
for (product p: products) {}
modify the product
updateProduct (p);
}
transaction.Commit ();
Products.Clear ();
}
Can I do so that I get at least each loop to have a time of constant treatment for ex every loop taking only 3 to 5 seconds to complete?
Currently, the time flow increases as the loop to continue processing the remaining records.
Thank you.Frank is right with his suggestion. A pl/sql procedure or an sql update statement (if all updates are the same) is best for update several lines.
To clarify my last post:
a VO can have only a single mode of access at any given time. Don't forget that you can switch the mode during execution. Range paging allows you to browse on all lines of the VO, before only not as its name suggests. Memory consumption is different because access only to the front only holds the level lines in memory. If you browse (forward) the memory of the old lines is released (when gc sets in). Therefore forward only has the smallest memory footprint (from ADFbc point of view) and can be used to manipulate the games the same outline. Still a pl/sql procedure is faster and more often the best choice.The workflow are:
1. use a VO in access mode forward only
2 run your query
3. use (vo.next ()) {...} to work on each lineIf you use the pagination of range rather than forward only you are able to use vo.prev () and other methods of navigation on the vo.
Timo
-
I have an accmaster say table where each record has detailts on an acct as actno, curr_bal, branch, acct_type I want something as below a
branch_no - Sum (curr_bal) where acct_type like 1% ' as sb - sum (curr_bal) where acct_type like 2%'s fd of the Group table by branch in a single line as shown below
00001 550000 65000000
00002 75909000 2568229867
Please tell how to do the above operation.Hello
This is called a Pivot , and here's a way to do it:
SELECT branch_no , SUM (CASE WHEN acct_type LIKE '1%' THEN curr_bal END) AS total_1 , SUM (CASE WHEN acct_type LIKE '2%' THEN curr_bal END) AS total_2 FROM accmaster GROUP BY branch_no ;
This will work in any version of Oracle, from 8.1, but starting in Oracle 11.1, you can also use the SELECT... Function PIVOT.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.Furthermore, your table is called
accmaster (where, I guess, ACC means 'account') and it contains called columns
ACTNO ( Act means 'account') and
acct_type ( acct means 'account')
Do you really need 3 different ways to shorten "account"? How do you recall when you used a way and when you have used another or when you used an underscore after the abbreviation character, and when you do not have? Even if you never get confused by these things, someone trying to help you, and one that should keep your code in the future, will probably. Do not use consistent, such as namespace
acct_master
Acct_No and
acct_type
? -
Confirmation of dashboard does not display the desired results
Hello
I have confirmation created using this condition. But it does not show me the results. The code seems to be correct.any help please...
-case when TimeStampDiff (SQL_TSI_DAY, "TB1". CL1, CURRENT_DATE) between 0 and 30 or TimeStampDiff (SQL_TSI_DAY, "TB1". Cl2, CURRENT_DATE) between 0 and 30, then 30 days
When TimeStampDiff (SQL_TSI_DAY, "TB1". CL1, CURRENT_DATE) between 31 and 60 or TimeStampDiff (SQL_TSI_DAY, "TB1". Cl2, CURRENT_DATE) between 31 and 60 then "60 days".
When TimeStampDiff (SQL_TSI_DAY, "TB1". CL1, CURRENT_DATE) between 61 and 90 or TimeStampDiff (SQL_TSI_DAY, "TB1". CL1, CURRENT_DATE) between 61 and 90 ' last 90 days.
another end '> 90 and max 100 days '.Hello
Create a dummy column for the code below
case when TimeStampDiff(SQL_TSI_DAY,"TB1".CL1,CURRENT_DATE) between 0 and 30 or TimeStampDiff(SQL_TSI_DAY,"TB1".CL2,CURRENT_DATE) between 0 and 30 then '30 days' when TimeStampDiff(SQL_TSI_DAY,"TB1".CL1,CURRENT_DATE) between 31 and 60 or TimeStampDiff(SQL_TSI_DAY,"TB1".CL2,CURRENT_DATE) between 31 and 60 then ' last 60 days' when TimeStampDiff(SQL_TSI_DAY,"TB1".CL1,CURRENT_DATE) between 61 and 90 or TimeStampDiff(SQL_TSI_DAY,"TB1".CL1,CURRENT_DATE) between 61 and 90 then 'last 90 days' else '> 90 and max 100 Days' end
filter as is invited for this column after that giving filter as it is prompting you can hide this column or remove it.
Save the report
Award points and to close the debate, if your question is answered.
See you soon,.
Aravind -
How to get the desired result of the post
Hi all.
I use APEX 4.0.
Now, I have two pages: A, B.
Transfer the student_id from page A to page B.
There is an article questioned B: student_name page select the CT where student_id =: student_id;
At the same time, I want to get the name of the student with the title of the region, I handle it like this: student name: & Student_Name. (with the '.') ;
If the bases of the student_name on column DB, the title work. After I have change student_name based on the query, it does not work.
How can I solve it. Thank you.Hi Andy,.
It depends on If the value is defined in this field. If you set the source of the element, it is probably too late for value must be used in the title of the region.
In general, I find that it is better to create a calculation that is running "Before Header" to set values in the page that I need to use when the page is loaded.
Andy
-
SQL query to get the given result
Hi friends
My data in the table are given below
user transaction_date transaction_type
1 1st August 2011
August 2, 2011 1 c
1 3 August 2011
1 b 3 August 2011
1 August 4, 2011 a
1 b 4 August 2011
2 3 August 2011
2 b 3 August 2011
August 4, 2011 2 c
2 b 4 August 2011
2 August 5, 2011 a
2 b August 5, 2011
2 August 7, 2011 a
2 b 7 August 2011
I want the count for each user as, how many times he made a transaction type transaction immediately after 'b' type?
As the output of above data should be
number of users
1 2
2 3
Thanks in advance :)Maybe (NOT TESTED).
select "user", count(criteria) "count" from (select "user", transaction_date, transaction_type, case when transaction_type = 'b' and lag(transaction_type,1) over (partition by "user",transaction_date order by transaction_date,transaction_type) = 'a' then 1 end criteria from the_table ) group by "user" order by "user"
Concerning
Etbin
-
Can do us a query to get the same results of 3 tables
CREATE TABLE TABLE1 (NODEID VARCHAR2 (4));
CREATE TABLE TABLE2 (NODEID VARCHAR2 (4));
CREATE TABLE TABLE3 (NODEID VARCHAR2 (4));
INSERT INTO TABLE1 VALUE('1004');
INSERT INTO TABLE1 VALUE('1004');
INSERT INTO TABLE1 VALUE('1002');
INSERT INTO TABLE1 VALUE('1002');
INSERT INTO TABLE1 VALUE('1001');
INSERT INTO TABLE1 VALUE('1001');
INSERT INTO TABLE1 VALUE('1006');
INSERT INTO TABLE1 VALUE('1006');
INSERT INTO TABLE1 VALUE('1005');
INSERT INTO TABLE1 VALUE('1005');
INSERT INTO TABLE2 VALUE('1004');
INSERT INTO TABLE2 VALUE('1004');
INSERT INTO TABLE2 VALUE('1004');
INSERT INTO TABLE2 VALUE('1002');
INSERT INTO TABLE2 VALUE('1002');
INSERT INTO TABLE2 VALUE('1002');
INSERT INTO TABLE2 VALUE('1002');
INSERT INTO TABLE 3 VALUE('1001');
INSERT INTO TABLE 3 VALUE('1001');
INSERT INTO TABLE 3 VALUE('1006');
INSERT INTO TABLE 3 VALUE('1006');
INSERT INTO TABLE 3 VALUE('1005');
INSERT INTO TABLE 3 VALUE('1005');
INSERT INTO TABLE 3 VALUE('1004');
INSERT INTO TABLE 3 VALUE('1004');
INSERT INTO TABLE 3 VALUE('1004');
INSERT INTO TABLE 3 VALUE('1002');
INSERT INTO TABLE 3 VALUE('1002');
INSERT INTO TABLE 3 VALUE('1002');
INSERT INTO TABLE 3 VALUE('1002');
SELECT count (*), count (distinct nodeid)
of table1, table2, table3
where table1.nodeid = table2.nodeid and table1.nodeid = table3.nodeid;
SELECT count (*), count (distinct nodeid)
FROM table1, table3
where table1.nodeid = table2.nodeid;
SELECT count (*), count (distinct nodeid)
from table2, table3
where table2.nodeid = table3.nodeid;SQL> SELECT MAX (CASE WHEN row_ind = 1 THEN ct END) ct_1, 2 MAX (CASE WHEN row_ind = 1 THEN distinct_ct END) distinct_ct_1, 3 MAX (CASE WHEN row_ind = 2 THEN ct END) ct_2, 4 MAX (CASE WHEN row_ind = 2 THEN distinct_ct END) distinct_ct_2, 5 MAX (CASE WHEN row_ind = 3 THEN ct END) ct_3, 6 MAX (CASE WHEN row_ind = 3 THEN distinct_ct END) distinct_ct_3 7 FROM (SELECT 1 AS row_ind, 8 COUNT (*) ct, 9 COUNT (DISTINCT table1.nodeid) distinct_ct 10 FROM table1, table2, table3 11 WHERE table1.nodeid = table2.nodeid 12 AND table1.nodeid = table3.nodeid 13 UNION ALL 14 SELECT 2 AS row_ind, COUNT (*), COUNT (DISTINCT table1.nodeid) 15 FROM table1, table3 16 WHERE table1.nodeid = table3.nodeid 17 UNION ALL 18 SELECT 3 AS row_ind, COUNT (*), COUNT (DISTINCT table2.nodeid) 19 FROM table2, table3 20 WHERE table2.nodeid = table3.nodeid) 21 / CT_1 DISTINCT_CT_1 CT_2 DISTINCT_CT_2 CT_3 DISTINCT_CT_3 ---------- ------------- ---------- ------------- ---------- ------------- 50 2 26 5 25 2
There may be an easier way...
Maybe you are looking for
-
how much will cost to get my iPhone 6 s fix
cracked glass iPhone 6s. What will it cost?
-
How to export the results of the DIAdem script to Excel sheet?-attachment
Please, this is the Script file for, y previous question?
-
Difficulties to show full screen Freecell
I recently had to reinstall Windows XP Media more and now I can't get Freecell to fill the full screen. It shows that on the fear that half of the screen and the button bigger makes half smaller. I would like suggestions.
-
I have long used now on Windows 7, Windows media Player and just got an update from Micorsoft. Set, now when I try to open the drive it tells me the the wmplayer file has a version number of 12.07600.16415 where 12.0.7600.16667 was expected. Windows
-
I am trying to download a digital copy of a movie that was recently PURCHASED. It says I need to update security for Windows Media and sends me to a link of Windows. The "update" button is not available to click. How do I put security update then?