Question on PIVOT() function
Hello everyone,
I have the below dataset and I would like to display it in the format that I've highlighted below:Please suggest.
ELEMENT_NAME
VALUE
PO Number
4500018345
Invoice Number
77777
Invoice Amount
95000
Supplier Name
ABC
PO Line Number
80
Invoice Date
2013-06-10
PO Line Number
70
Invoice Amount
5000
Supplier Name
CDF
Required format
Invoice Number
PO Number
Invoice Amount
Supplier Name
Invoice Date
PO Line Number
77777
4500018345
95000
ABC
2013-06-10
70
77777
4500018345
5000
CDF
2013-06-10
80
Yet another reason to avoid the EAV model.
Anyway, you could try something along these lines:
SQL> -- generating sample data:
SQL> with t as (
2 select 'PO Number' element_name, '4500018345' value from dual union
3 select 'Invoice Number', '77777' from dual union
4 select 'Invoice Amount', '95000' from dual union
5 select 'Supplier Name', 'ABC' from dual union
6 select 'PO Line Number', '80' from dual union
7 select 'Invoice Date', '2013-06-10' from dual union
8 select 'PO Line Number', '70' from dual union
9 select 'Invoice Amount', '5000' from dual union
10 select 'Supplier Name', 'CDF' from dual
11 )
12 --
13 -- actual query:
14 --
15 select nvl(invno, lag(invno) over (order by invno)) "Invoice Number"
16 , nvl(pono, lag(pono) over (order by pono)) "PO Number"
17 , nvl(invam, lag(invam) over (order by invam)) "Invoice Amount"
18 , nvl(supl, lag(supl) over (order by supl)) "Supplier Name"
19 , nvl(invdt, lag(invdt) over (order by invdt)) "Invoice Date"
20 , nvl(poline, lag(poline) over (order by poline)) "PO Line Number"
21 from ( select min(case when element_name = 'Invoice Number' then value end ) invno
22 , min(case when element_name = 'PO Number' then value end ) pono
23 , min(case when element_name = 'Invoice Amount' then value end ) invam
24 , min(case when element_name = 'Supplier Name' then value end ) supl
25 , min(case when element_name = 'Invoice Date' then value end ) invdt
26 , min(case when element_name = 'PO Line Number' then value end ) poline
27 from ( select element_name
28 , value
29 , row_number() over (partition by element_name order by value) rn
30 from t
31 )
32 group by rn
33 );
Invoice Nu PO Number Invoice Am Supplier N Invoice Da PO Line Nu
77777 4500018345 5000 ABC 2013-06-10 70
77777 4500018345 95000 CDF 2013-06-10 80
2 rows selected.
Similar Messages
-
Pivot function in Oracle 10g???
Hello everybody,
at the beginning of the week I had a simple problem (I thought that...), but now after trying and trying, I can't find a solution for it. First of all I'm working on Oracle 10g with the version 10.2.0.4.0. I can't change the version, it's standard in the whole company...
At the beginning I have a table like the following one, but please note, that the compartment, the type and the amount are flexible and can change at any time:
comp type amount
a1 6280 10
a2 6280 20
a2 4810 15
a2 1147 12
a3 6280 33
Now I want the table to look like this:
a1 a2 a3
1147 0 12 0
4810 0 15 0
6280 10 20 33
A simple question in Excel for example, I just use the pivot function and have it fixed within 10seconds. But how can I do sth. like this in Oracle with simple SQL? Or it can be PL/SQL too, cause I will use this in an APEX application.
Can you please give me a hint or a solution? But as stated before a1, a2, a3 are just examples it is possible that tomorrow a4, a5 and so on are coming. If it is necessary I can also create additional tables and views of course!
Thanks for your help!
Regards
hogeHi Hoge!
Here is your solution:
SELECT TYPE,
sum(a1) AS a1,
sum(a2) AS a2,
sum(a3) AS a3
FROM (SELECT TYPE,
decode(comp, 'a1', amount, 0) AS a1,
decode(comp, 'a2', amount, 0) AS a2,
decode(comp, 'a3', amount, 0) AS a3
FROM test)
GROUP BY TYPE
ORDER BY TYPE; And here is my test case setup:
CREATE TABLE test
(comp VARCHAR2(255),
TYPE NUMBER,
amount NUMBER);
INSERT INTO test(comp, TYPE, amount) VALUES('a1', 6280, 10);
INSERT INTO test(comp, TYPE, amount) VALUES('a2', 6280, 20);
INSERT INTO test(comp, TYPE, amount) VALUES('a2', 4810, 15);
INSERT INTO test(comp, TYPE, amount) VALUES('a2', 1147, 12);
INSERT INTO test(comp, TYPE, amount) VALUES('a3', 6280, 33);
commit;Best regards,
Matt -
How to use Pivot function for group range in oracle SQL
Hi,
Good Morning !!!
I need to show the data in the below format. There is 2 columns 1 is State and another one is rate.
State <100 100-199 200-299 300-399 400-499 500-599 600-699 700-799 800-899 900-999 >=1000 Total
AK 1 2 0 4 1 4 4 35 35 4 1 25
AL 0 0 2 27 10 17 35 2 2 35 0 103
AR 0 0 1 0 0 2 2 13 13 2 0 6
AZ 0 1 2 14 2 14 13 3 3 13 0 57
CA 0 0 1 6 2 7 3 4 4 3 0 34
Developed the below query but unable to use the range on pivot function . Please help on this.
(select (SELECT SHORT_DESCRIPTION
FROM CODE_VALUES
WHERE CODE_TYPE_CODE = ad.STATE_TYPE_IND_CODE
AND VALUE = ad.STATE_CODE
) STATE,
nr.rate
FROM neutrals n,
contacts c,
addresses ad,
xref_contacts_addresses xca,
neutral_rates nr
where n.contact_id=c.contact_id
and n.address_id = ad.address_id
and xca.address_id=ad.address_id
and xca.contact_id=c.contact_id
and nr.contact_id = n.contact_id
and nr.rate_frequency='HOUR' )user8564931 wrote:
This solutions is useful and Thanks for your reply.
How can i get the Min value and Max value for each row ?
State <100 100-199 200-299 300-399 400-499 500-599 600-699 700-799 800-899 900-999 >=1000 Total Min Max
IL 0 0 1 5 1 5 40 1 1 40 0 53 $10 $2,500
IN 0 0 0 0 0 0 1 49 49 1 0 3 $70 $1,500This?
WITH t AS
(SELECT 'AL' state, 12 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 67 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 23 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 12 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 12 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 78 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 34 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 4 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 12 VALUE FROM DUAL
UNION ALL
SELECT 'AL' state, 15 VALUE FROM DUAL
UNION ALL
SELECT 'AZ' state, 6 VALUE FROM DUAL
UNION ALL
SELECT 'AZ' state, 123 VALUE FROM DUAL
UNION ALL
SELECT 'AZ' state, 123 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 23 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 120 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 456 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 11 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 24 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 34 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 87 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 23 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 234 VALUE FROM DUAL
UNION ALL
SELECT 'MA' state, 789 VALUE FROM DUAL
UNION ALL
SELECT 'MH' state, 54321 VALUE FROM DUAL),
-- End of test data
t1 AS
( SELECT state,
NVL (COUNT (DECODE (VALUE, 0, 0)), 0) "<100",
NVL (COUNT (DECODE (VALUE, 1, 1)), 0) "100-199",
NVL (COUNT (DECODE (VALUE, 2, 2)), 0) "200-299",
NVL (COUNT (DECODE (VALUE, 3, 3)), 0) "300-399",
NVL (COUNT (DECODE (VALUE, 4, 4)), 0) "400-499",
NVL (COUNT (DECODE (VALUE, 5, 5)), 0) "500-599",
NVL (COUNT (DECODE (VALUE, 6, 6)), 0) "600-699",
NVL (COUNT (DECODE (VALUE, 7, 7)), 0) "700-799",
NVL (COUNT (DECODE (VALUE, 8, 8)), 0) "800-899",
NVL (COUNT (DECODE (VALUE, 9, 9)), 0) "900-999",
NVL (COUNT (DECODE (VALUE, 10, 10)), 0) ">=1000"
FROM (SELECT state,
CASE
WHEN VALUE < 100 THEN 0
WHEN VALUE BETWEEN 100 AND 199 THEN 1
WHEN VALUE BETWEEN 200 AND 299 THEN 2
WHEN VALUE BETWEEN 300 AND 399 THEN 3
WHEN VALUE BETWEEN 400 AND 499 THEN 4
WHEN VALUE BETWEEN 500 AND 599 THEN 5
WHEN VALUE BETWEEN 600 AND 699 THEN 6
WHEN VALUE BETWEEN 700 AND 799 THEN 7
WHEN VALUE BETWEEN 800 AND 899 THEN 8
WHEN VALUE BETWEEN 900 AND 999 THEN 9
WHEN VALUE >= 1000 THEN 10
END
VALUE
FROM t)
GROUP BY state)
SELECT STATE,
"<100",
"100-199",
"200-299",
"300-399",
"400-499",
"500-599",
"600-699",
"700-799",
"800-899",
"900-999",
">=1000",
"<100"
+ "100-199"
+ "200-299"
+ "300-399"
+ "400-499"
+ "500-599"
+ "600-699"
+ "700-799"
+ "800-899"
+ "900-999"
+ ">=1000"
total,
least("<100",
"100-199",
"200-299",
"300-399",
"400-499",
"500-599",
"600-699",
"700-799",
"800-899",
"900-999",
">=1000") min_val,
greatest("<100",
"100-199",
"200-299",
"300-399",
"400-499",
"500-599",
"600-699",
"700-799",
"800-899",
"900-999",
">=1000") max_val
FROM t1
/ -
Hi all,
One thing i'm struggling with is the use of the pivot function to pivot a column within PQ. I'm confused on why this happens and why I can't clear it up...but here goes:
I unpivot a set of columns which then gives me two columns (Attribute/Value). I do this because I have repeated columns of data, but it should all fall under one column (think Hours, Hours1, Hours2, etc) - basically the input is coming from a form
that has repeating fields but everything is the same data type.
I make some adjustments to the Attribute columns (Replace items within the Attribute column) then Pivot the two columns again...theoretically I would be able to do this since i just unpivoted the same data, but:
I get tons of errors (usually "There were too many elements in the enumeration to complete the operation".). I'm not entirely sure why this happens and it doesn't seem to make sense to me that I can't UnPivot and Pivot and get the same results
as I originally had.
Any recommendations would be greatly appreciated!
EDIT: I'm choosing "don't aggregate" during the Pivot operation...I get values if I keep some sort of aggregate function, but not the right values (I get a count of the fields instead of the data within the fields)Try this solution:
Once you are to step 3, add an index column that starts at 0 and another index column that starts at 1.
Transform by Pivot Column using the names in Attribute to create new columns and the Values Column set to Value. Under advanced options select Don't Aggregate.
Fill Down the Date column
Filter rows to remove null from Work Time.
Here's the M code from the advanced editor:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
#"Added Index1" = Table.AddIndexColumn(#"Added Index", "Index.1", 1, 1),
#"Pivoted Column" = Table.Pivot(#"Added Index1", List.Distinct(#"Added Index1"[Attribute]), "Attribute", "Value"),
#"Filled Down" = Table.FillDown(#"Pivoted Column",{"Date"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Work Time] <> null)),
#"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"Work Time", type time}})
in
#"Changed Type"
If that doesn't work, this example might do the trick:
http://www.excelguru.ca/blog/2015/01/07/transpose-stacked-tables/ -
Hi all,
In pivot function "in" clause i want to use sql query, because i want to take values dynamically from the table.
How can i use, is there any solution for that.
Pls help me.
maniHere's what I was thinking:
SQL> DECLARE
2 yrno NUMBER;
3 x VARCHAR2(100) := '''direct'' AS Store, ''online'' AS Internet';
4 BEGIN
5 SELECT year
6 INTO yrno
7 FROM
8 (SELECT EXTRACT(YEAR FROM order_date) year, order_mode, order_total FROM orders)
9 PIVOT
10 (SUM(order_total) FOR order_mode IN (x))
11 WHERE rownum = 1;
12
13 dbms_output.put_line(yrno);
14 END;
15 /
(SUM(order_total) FOR order_mode IN (x))
ERROR at line 10:
ORA-06550: line 10, column 40:
PL/SQL: ORA-56901: non-constant expression is not allowed for pivot|unpivot values
ORA-06550: line 5, column 3:
PL/SQL: SQL Statement ignoredWith the value of "x" easily created dynamically. Now all I can say is:
Ouch ... I've been taken out to the woodshed and beaten.
I am sending in an enhancement request for version 12.
If you agree that this is something we need please log onto metalink and do so too. Thank you. -
Question about 2 functions.
OK, new question from me.
I have two functions, bassicly they are smilar, but the problem is that I need that second function to start up or become active, after certain amount of time or when "x" reaches 1000. How can I do this?
And second question is, both functions make objects apper on stage in exact coordinates (5 spots), how can I make that objects woun't apper on the same spot, bassicly it would check if that position is occupied, it chooses other spot. (spot choosing is performed by random)
Oh, and third question.
I want to make the object to be active for two seconds, and then it disapper, my thought was to make tween, but couldn't find the type of appearance.1. You can check the condition to determine if you should do something, i.e.
if (x >= 1000) {
// do something
2. First randomise an Array [Spot 1, Spot 2, Spot 3, Spot 4, Spot 5], then place your object to the spot in the order of the array item.
3. My favorite way is to use TweenLite.delayedCall(). For example if you want to remove something in 2 seconds time you do:
TweenLite.delayedCall(2, remove, [anObject]);
function remove(displayObject:DisplayObject):DisplayObject {
return removeChild(displayObject);
(You can use Timer class etc for this but TweenLite wins always ) -
Question about the function module (RFC_READ_TABLE)
Dear everyone
Could I ask you a question about the function module (RFC_READ_TABLE)?
I was asked if it's possible to create a report which compares the data between different SAP systems (both production systems).
Now, the easiest way would be to use the function module (RFC_READ_TABLE) within a SAP infoset query (SQ01 type query).
But I heard the rumor that using the function module (RFC_READ_TABLE) is not advisable due to the security reason.
However, I am not exactly sure what sort of security problems this function module can possibly have...
Would you help me on this?
I also would like to know if using "remote enabled module" type function module can always overcome this possible security issue.
Or, are there any points that I need to be careful about even when I use "remote enabled module" function module?
Thank you very much in advance.
TakashiDear Fred-san
Thank you very much for your support on this.
But, may I double check about what you mentioned above?
So, what you were mentioning was that if some user executes the query with
the function module (RFC_READ_TABLE), under the following conditions, he can access to
the HR data even when he does not have the authorizations for HR transactions?
<Conditions>
1. the user has the authorization for HR database tables themselves
2. RFC_READ_TABLE is called to retrieve the data from HR database
<example>
Data: LF_HR_TABLE like DD02L-TABNAME value 'PA0000'.
CALL FUNCTION 'RFC_READ_TABLE'
EXPORTING
query_table = LF_HR_TABLE
TABLES
OPTIONS =
fields =
data = .
But then, as long as we call this function module for a non-critical tables such as
VBAP (sales order) or EKKO (purchase order) within our query, it wouldn't seem to be
so security risk to use RFC_READ_TABLE...
Besides, each query (infoset query) has got the concept of user groups, which limits
the access to the queries within the user group.
※If someone does not belong to the user group, he cannot execute the queries within that
user group, etc
So, my feeling is that even infoset queries does have authorization concept...
Would you give me your thought on this?
I also thank you for your information for SCU0.
That is an interesting transaction
Kind regards,
Takashi -
Oracle rows to columns/pivot function
Does anyone have any experience using the oracle pivot function? I have two tables:
Table1:Users
Username
jsmith
jjohnson
jbeck
Table2:Job Codes
Username,Job Code
jsmith,JC1
jsmith,JC2
jsmith,JC3
jbeck,JC2
I'm looking to formulate a query that will allow me to join the two tables and at the same time have the rows from table2 represented as columns (assuming a max of 3 job codes):
Username,JobCode1,JobCode2,JobCode3
jsmith,JC1,JC2,JC3
jbeck,JC2,,
It seems like pivot is the function I want to use for this but I can't seem to correlate the examples online back to what we're trying to do.Hi,
Welcome to the forum!
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.
See the forum FAQ {message:id=9360002}
Since I don;t have a version of your table, I'll use the scott.emp table.
I think you want something like this:
WITH got_r_num AS
SELECT job, ename
, ROW_NUMBER () OVER ( PARTITION BY job
ORDER BY ename
) AS r_num
FROM scott.emp
SELECT *
FROM got_r_num
PIVOT ( MIN (ename)
FOR r_num IN ( 1 AS name_1
, 2 AS name_2
, 3 AS name_3
ORDER BY job
;This shows up to 3 names from each job
JOB NAME_1 NAME_2 NAME_3
ANALYST FORD SCOTT
CLERK ADAMS JAMES MILLER
MANAGER BLAKE CLARK JONES
PRESIDENT KING
SALESMAN ALLEN MARTIN TURNERIf there are more than 3 rows with the same job, only the first 3 (in alphabetic order; that's what the analytic ORDER BY clause is doing) will be shown. For example, there's another SALESMAN named WARD who is not shown above.
This query requires Oracle 11.1 (or higher).
For other pivot techniques, including ones for earlier versions, see the forum FAQ {message:id=9360005}
Edited by: Frank Kulash on May 25, 2012 10:20 AM
Added output -
Issues with use of PIVOT function
I have a single table that gives me a Value ID for each record. There are 1-3 of them for each Dim ID. The Name values of these can be found in a 2nd table, by the Value ID from the first table. I feel like this can be handled with the pivot function, but
I'm having trouble figuring out how to set it up properly.
Samples are below. Top left is table 1. Top right is table 2. Bottom is how I need the data to be captured in a query.DECLARE @dimValue TABLE (dimID INT, valueID INT)
INSERT INTO @DimValue (dimID, valueID)
VALUES
(6,1),(6,10),(6,14),(8,3)
DECLARE @dimNames TABLE (valueID int, name varchar(50), type varchar(10))
INSERT INTO @DimNames (valueID, name, type)
VALUES
(1,'George','First'),(10,'Micheal','Middle'),(14,'Johnson','Last'),(3,'Stan','First')
-- without pivot
SELECT v.dimID, MAX(f.name) AS first, MAX(m.name) AS middle, MAX(l.name) AS last
FROM @dimValue v
LEFT OUTER JOIN @dimNames f
ON v.valueID = f.valueID
AND f.type = 'first'
LEFT OUTER JOIN @dimNames m
ON v.valueID = m.valueID
AND m.type = 'middle'
LEFT OUTER JOIN @dimNames l
ON v.valueID = l.valueID
AND l.type = 'last'
GROUP BY v.dimID
--pivot
SELECT DimID, MAX(first) AS first, MAX(middle) AS middle, MAX(last) AS last
FROM @dimNames n
PIVOT (MAX(Name) FOR type IN (FIRST, middle, last)) pvt
INNER JOIN @dimValue v
ON pvt.valueID = v.valueID
GROUP BY dimID
This shows you how to do it with and without a pivot.
Please don't post data as images. You force us to manually type it.
Refer to the top of the code to see one way to give us demo data and objects. -
Samsung TFT 244T pivot function with Nvidia Geforce 6600LE
I have a Nvidia Geforce 6600LE installed in my powermac g5.
I am interested in the Samsung 244 T display but I am not sure if the pivot function will work with my current graphic card.
Any help would be appreciated.
http://www.macoteket.se/productlist.jsp?group_id=945456&productid=841409
Powermac G5 2.2 ghz Mac OS X (10.4.8)Hi Ingvar-
Do you have the Nvidia Forceware software? Inside of that is NVRotate software that allows rotation of monitors.
The Samsung uses proprietory software- their software (comes with the screen) is used when the screen is rotated.
Either way, it should work.
G4 AGP(450)Sawtooth Mac OS X (10.4.8) 2ghzPPC,1.62gbSDRAM, ATI9800, DVR-109,(IntHD)120&160,LaCie160,23"Cinema Display -
Questions on the functionality of Crystal Reports 2011
Dear all ,
i recently got in contact with Cyrstal Reports and have to conduct an analysis about its functionalities and possibilites.
I have some questions which could not be answered using internet research and would be very happy if some of you (who are certainly more experienced) could give me some short answers on them.
1. I know that you need SAP NetWeaver in order to run Business Objects Analyits for MS Offic, but do i need the NetWeaver application also for Cyrstal Reports (CR) ? In my case I have an Oracle database and have not the possibility to change to a Netweaver data warehouse
2. I have a PPT Master document (with predefined action titles, headings etc.). Is it possible to create my charts with CR and then automatically integrate them in my Powerpoint Master? I know that CR can create .png (and other) but I want that the user can change the diagram in powerpoint (e.g. changing colours)
Is that possible ?
3. When having a direct connection to Powerpoint, is there a way that i can identify updated graphics ? I´m thinking of some kind of red dot that symbolized users that this graphic has changed.
4. Is there a way to integrate CR directly in PPT that users have the possibility to create reports in PPT or do I always have to use the CR interface?
Would be very happy if you just could give me some brief answers on the questions cause I have not much experience in the field (as my questions already indicate Wink )
Thanks and Greetings,
DanGood afternoon. I have attempted to address your questions below. Please review my answers and let me know if you need more details.
Regards,
Coy
Product Manager - SAP Crystal Reports
1. I know that you need SAP NetWeaver in order to run Business Objects Analyits for MS Offic, but do i need the NetWeaver application also for Cyrstal Reports (CR) ? In my case I have an Oracle database and have not the possibility to change to a Netweaver data warehouse
Crystal Reports does not require SAP NetWeaver in order to function. In fact, Crystal Reports is a desktop tool used to create reports. You can then publish those reports to the SAP BusinessObjects BI Platform, embed them in custom applications, or view them directly via a desktop viewer (or in another format).
2. I have a PPT Master document (with predefined action titles, headings etc.). Is it possible to create my charts with CR and then automatically integrate them in my Powerpoint Master? I know that CR can create .png (and other) but I want that the user can change the diagram in powerpoint (e.g. changing colours)
Is that possible ?
It is possible to integrate Crystal Reports content directly into Microsoft Office documents by using the SAP BusinessObjects LiveOffice tool.
3. When having a direct connection to Powerpoint, is there a way that i can identify updated graphics ? I´m thinking of some kind of red dot that symbolized users that this graphic has changed.
This is not possible "out of the box", but may be possible via some custom addon.
4. Is there a way to integrate CR directly in PPT that users have the possibility to create reports in PPT or do I always have to use the CR interface?
Please see the answer above for #2.
Edited by: Coy Yonce on Jul 25, 2011 11:01 PM
Edited by: Coy Yonce on Jul 25, 2011 11:02 PM -
Question on the function okFindIndex
Hello all,
I have some questions on programming palm application by using Olite502 and codewarrior.
In the palm database, there is a table call PDA_CASE, I that table, there are 4 fields, i.e. CASE_NO, ID, TEL, ADDRESS.
Now, in my application, i have create an index with the field(ID and TEL). The code is as follow:
err = okCreateIndex( env, grpCaseSummary2Ref, clsCaseSummary2Ref, 2, (okU4B*)indexCaseSummaryBy_cin, OK_BTREE, OK_PRIMARY_KEY, &idxCaseSummary_cin );
Now, Can I ask how to use the function okFindIndex to return the key, so that I can use the function okCreateIterator to retrieve the data in my specified order?
Thanks
KewellHi,
Do you still need help w/ this post or has it already been resolved?
Thank you. -
Few questions about sql2008 functions and commands
hello,
I am learning sql2008 implementation and maintenance,I am just 2 weeks bussy.there is some questions in my mind wich I can't answer it.
1-when I can use USE MASTER statement
2-can a database for example (test) have many and unlimmited file groups?
3-what is the diferrence between file and filegroup! is the term of file means tables in filegroup?
4-with boundary points does mean the data type when creating partition function!
5`what is diferrence between full text index and index,where you have to use the index and wher you have to use full text index?
6-each filegroup must have one partition or one partition can have many filegroups in partition scheme!
7-do you have to partition every scheme or not! where do you have to partition a scheme and where not?
8-can you give a little example with switch operator!
9-again do you have to partition every table and index in the real world or not!
thanks
johan
h.davidHi,
Let me try to answer your questions:
You need to use USE MASTER whenever you need to do some work in the MASTER database and the database context is not that.
Yes, a database can have many filegroups. Please check this article:
http://msdn.microsoft.com/en-us/library/ms179316.aspx
Please check this article:
http://msdn.microsoft.com/en-us/library/ms179316.aspx
As per BOL:
boundary_value is a constant expression that can reference variables. This includes user-defined type variables, or functions and user-defined functions. It cannot reference Transact-SQL expressions.
boundary_value must either match or be implicitly convertible to the data type supplied in
input_parameter_type, and cannot be truncated during implicit conversion in a way that the size and scale of the value does not match that of its corresponding
input_parameter_type. For more details check
http://msdn.microsoft.com/en-us/library/ms187802.aspx
For simplicity: Full-Text index is used to search in a LOB/text data in a column, index is used to speed up your queries. Please check these articles:
http://msdn.microsoft.com/en-us/library/ms142571.aspx,
http://msdn.microsoft.com/en-us/library/ms189271.aspx
As per BOL: When you create a partition scheme, you define the filegroups where the table partitions are mapped, based on the parameters of the partition function. You must specify enough filegroups to hold the number of partitions. You can specify that
all partitions map to a different filegroup, that some partitions map to a single filegroup, or that all partitions map to a single filegroup. You can also specify additional, "unassigned" filegroups in the event you want to add more partitions later. For
more info, please check
http://msdn.microsoft.com/en-us/library/ms188730.aspx
8. Please read the concept of partitioning here:
http://msdn.microsoft.com/en-us/library/ms190199.aspx and for SWITCH operator, please check the sliding window example at here:
http://msdn.microsoft.com/en-us/library/aa964122(SQL.90).aspx
9. It depends :) but you always will have at least 1 partition!
I hope it helps.
J.
There are 10 type of people. Those who understand binary and those who do not. -
Question regarding decode function.
Hi friends,
I have a question regarding using decode.
I'm try'g to explain my problem using emp table.
Can you guys please help me out.
For example consider emp table, now i want to get all manager id's concatenated for 2 employees.
I tried using following code
declare
v_mgr_code number(10);
v_mgr1 number(4);
v_mgr2 number(4);
begin
select mgr into v_mgr1
from scott.emp
where empno = 7369;
select mgr into v_mgr2
from scott.emp
where empno = 7499;
select v_mgr1||'-'||v_mgr2 into v_mgr_code from dual;
end;now instead of writing 2 select statements can i write one select statement using decode function ?
Edited by: user642856 on Mar 8, 2009 11:18 PMi don't know wheter your looking for this or not.if i am wrong correct me.
SELECT Ename||' '||initcap('manager is ')||
DECODE(MGR,
7566, (SELECT Ename
FROM Emp
WHERE Empno = 7566),
7698, (SELECT Ename
FROM Emp
WHERE Empno = 7698),
7782, (SELECT Ename
FROM Emp
WHERE Empno = 7782),
7788, (SELECT Ename
FROM Emp
WHERE Empno = 7788),
7839, (SELECT Ename
FROM Emp
WHERE Empno = 7839),
7902, (SELECT Ename
FROM Emp
WHERE Empno = 7902),
'Do Not Know') Manager from empor
SELECT Ename||' '||initcap('manager is ')||
DECODE(MGR,
7566, (SELECT empno
FROM Emp
WHERE Empno = 7566),
7698, (SELECT empno
FROM Emp
WHERE Empno = 7698),
7782, (SELECT empno
FROM Emp
WHERE Empno = 7782),
7788, (SELECT empno
FROM Emp
WHERE Empno = 7788),
7839, (SELECT empno
FROM Emp
WHERE Empno = 7839),
7902, (SELECT empno
FROM Emp
WHERE Empno = 7902)) manager
from empEdited by: user4587979 on Mar 8, 2009 9:52 PM -
Complicated PL/SQL questions that involves function with in type parameter
Hello,
I have a question about functions with in-parameters. In the HR schema, I need to get the minimum salary of the job_id that is mentioned as an in-parameter.
this is what I am thinking but I dont know if it's correct or not or what should I do next!
create or replace function get_min_salary (i_job_id in varchar2)
return number
as
min_sal jobs.min_salary%type;
begin
SELECT min_salary INTO min_sal
FROM jobs
where job_id = i_job_id;
RETURN min_sal;
end get_min_salary;if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:
create or replace procedure insert_error (i_error_code in number,
i_error_message in varchar2)
as
begin
insert into error_table (error_user, error_date, error_code, error_message)
values (user,sysdate,i_error_code,i_error_message);
end insert_error;This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
Any ideas of how to do that?
Thanks in advance>
minimum salary of the job_id
>
may be
SELECT min(min_salary) INTO min_sal
FROM jobs
where job_id = i_job_id;
if the i_job_id which is the in type parameter does not have a minimum salary then use the following function to register an error:why error?
This function is basically to say that an error has occured and to register that error, at the same time I need to print out the error using the dbms_out.put_line.
create or replace procedure insert_error (i_error_code in number,
i_error_message in varchar2)
as
begin
insert into error_table (error_user, error_date, error_code, error_message)
values (user,sysdate,i_error_code,i_error_message);
-- this
dbms_out.put_line('this');
end insert_error;
Maybe you are looking for
-
So we just got a new computer and I was able to successfully add my iPod/library to it. However when I tried to add my husbands iPod/library to the computer his library didn't show up. He is ony able to charge his iPod but cannot see his library. I t
-
I keep losing my new bookmarks after I Sign off Safari and Sign in again
I transfered my bookmarks over from my other computer and I am trying to add more bookmark folders, after I am done and quit Safari, later go back to Safari and everything I have added is gone, Back to where I was before. Why is this happening and
-
I currently have my CS5.5 loaded on two windows laptops. I am replacing one of those laptops with a MacBook Pro. Can I deactivate the CS5.5 on the my old Windows laptop and activate a Mac version on the MacBook Pro? Or do they both activations hav
-
Playing AVI files on Snow Leopard
I am running Snow Leopard on both an iMac and a MacBook Pro. On the MBP I can play an AVI file. On the iMac, I cannot. I get an error saying "The document "xxxxx.avi" could not be opened. The movie is not in a format that QuickTime Player understands
-
I bought an iphone 5 from one of my friends and unluckily I had yet lost his contact, I had update this iphone to IOs 7 and now it's be locked at iCloud because there was no password . Actually I dont know what I must do for its. Experts, please help