How will write SQL query to fetch data from each Sub-partition..
Hi All,
Anyone does have any idea about How to write SQL query to fetch data from Sub-partition.
Actually i have one table having composite paritition(Range+list)
Now if i want to fetch data from main partition(Range) the query will be
SELECT * FROM emp PARTITION(q1_2005);
Now i want to fetch data at sub-partition level(List) .But i am not able to get any SQL query for that.
Pls help me to sort out.
Thanks in Advance.
Anwar
SELECT * FROM emp SUBPARTITION(sp1);
Similar Messages
-
Please let me know how to write the Query to fetch data from tables
Hi Folks,
Please let me know how to get the data from different tables using the functionality SQ03,SQ02 and SQ01 .
Helpful answers will points awarded.
Regards,
Ram.Dear Ram,
Please find the below link which gives in detail with screen shots.
[SAP Query|http://media.techtarget.com/searchSAP/downloads/Teach_yourself_SAP_C20.pdf#search=%22CREATE%20REPORT%20USING%20SQVI%20%2C%20SAP%22]
Thanks
Murtuza -
How to write sql query for counting pairs from below table??
Below is my SQL table structure.
user_id | Name | join_side | left_leg | right_leg | Parent_id
100001 Tinku Left 100002 100003 0
100002 Harish Left 100004 100005 100001
100003 Gorav Right 100006 100007 100001
100004 Prince Left 100008 NULL 100002
100005 Ajay Right NULL NULL 100002
100006 Simran Left NULL NULL 100003
100007 Raman Right NULL NULL 100003
100008 Vijay Left NULL NULL 100004
It is a binary table structure.. Every user has to add two per id under him, one is left_leg and second is right_leg... Parent_id is under which user current user is added.. Hope you will be understand..
I have to write sql query for counting pairs under id "100001". i know there will be important role of parent_id for counting pairs. * what is pair( suppose if any user contains both left_leg and right_leg id, then it is called pair.)
I know there are three pairs under id "100001" :-
1. 100002 and 100003
2. 100004 and 100005
3. 100006 and 100007
100008 will not be counted as pair because it does not have right leg..
But i dont know how to write sql query for this... Any help will be appreciated... This is my college project... And tommorow is the last date of submission.... Hope anyone will help me...
Suppose i have to count pair for id '100002'. Then there is only one pair under id '100002'. i.e 100004 and 100005Sounds like this to me
DECLARE @ID int
SET @ID = 100001--your passed value
SELECT left_leg,right_leg
FROM table
WHERE (user_id = @ID
OR parent_id = @ID)
AND left_leg IS NOT NULL
AND right_leg IS NOT NULL
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to write sql query with many parameter in ireport
hai,
i'm a new user in ireport.how to write sql query with many parameters in ireport's report query?i already know to create a parameter like(select * from payment where entity=$P{entity}.
but i don't know to create query if more than 1 parameter.i also have parameter such as
$P{entity},$P{id},$P{ic}.please help me for this.
thanksYou are in the wrong place. The ireport support forum may be found here
http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=showcat&catid=9 -
How to write sql query for below mentioned eaxmple.
Hi,
I have requirement.
There are number of rows and I need the result through query as follows.Please help me to proved sql query for below mentioned requirement.
example: table TEST.
COLA COLB COLC COLD COLE COLF MANAGER 5 NULL NULL 3 NULL
SR.MANAGER 6 3 NULL NULL NULL
VP 5 5 4 5 5
I have to write the sql query if COLA IS MANAGER THEN CONSIDER MANGER RECORD,AND IF ANY COLUMN FILED IS NULL FOR MANGER THEN CONSIDER COLA IS SR.MANGER, AND IF ANY COLUMN FILED IS NULL FOR SR,MANGER THEN CONSIDER VP records.
I need output as below.
COLB COLC COLD COLE COLF
5(manager) 3(sr.manger) 4(vp) 3(manger) 3(vp)
Please provide the for above mentioned output.
ThanksDuplicate thread. please view the answer posted in your first thread.
how to write sql query.
And, please don't post any duplicate thread.
Regards.
Satyaki De. -
SQL query to fetch records from 26 onwards
Want to know SQL query to fetch records from 26 onwards.
See the fifth entry on the FAQ page:
Re: How to attach a java bean in forms6i -
How to write SQL query and apply aggregate functions on it
Hello experts,
Iu2019ve a task to write SQL query on tree tables and do inner join on them. Iu2019ve accomplish this task by using T-CODE SQVI. However now I need to write a query and apply SQL functions on it i.e. Add, Count, Max and Min etc. Please can someone tell me how I can write SQL query with aggregate functions in SAP?
Thanks a lot in advanceHI Mr. Cool
you can see the below code for using aggregate functions.
where ARTIST and SEATSOCCU are the field names for which you want to perform these functions.
DATA: TOTAL_ENTRIES TYPE I,
TOTAL_ATT TYPE I,
MAX_ATT TYPE I,
AVG_ATT TYPE I.
SELECT COUNT( DISTINCT ARTIST )
SUM( SEATSOCCU )
MAX( SEATSOCCU )
AVG( SEATSOCCU ) FROM YCONCERT INTO (TOTAL_ENTRIES, TOTAL_ATT,
MAX_ATT, AVG_ATT).
Thanks
Lalit Gupta -
Using Query to fetch data from xml file
Hi guys ,
Just want to know , how to fetch data from an XML file in adobe flex? i have a database generated xml file.you can use httpService.
-
Sql query to fetch data based on date conditons
Hi All,
We have to schedule a script that runs at 1:00 AM from Monday to Friday.
The script will run a sql query ,that will fetch the data from sql database 2008 based on the below conditions.
Case 1: If date = current Date then retrieve the data of the previous Date.
Case 2: If date = Monday then retrieve the entries of Friday ,Saturday and Sunday.
Please help us on how we can achieve this.
ThanksHi,
Are you asking about Patrick's
solution?
If so I highly recommend NOT to use this solution. PLease read LMU92's
and
Visakh16's responses.
Why not to use it?
1. This solution is not deterministic!
A deterministic algorithm is an algorithm which, given a particular input, will always produce the same output. This solution give different values for different setting! It is depending for example on "SET LANGUAGE" value
As mentioned above if you try to use any other languge then English then this query will not work since you will never get the value "Sunday"
2. Moreover! Even if you are using "SET LANGUAGE 'English'" then this
solution depend on "SET DATEFIRST" and only take into consideration that the value can be 1 or 7, using any other value you will get that @weekendDateMod is null!
What can you use?
let's test some value first to get the solution yourself. We know that we don't care about "SET LANGUAGE" since I will not use any language dependency but we need to examine "SET DATEFIRST". Try to change the value from 1 to 7 and check
the value of this query
SET DATEFIRST 1 -- Change this value from 1 to 7!
DECLARE @Sunday DATE = '2014-08-03' -- This is Sunday
DECLARE @Munday DATE = '2014-08-04' -- This is Munday
SELECT DATEPART(DW,@Sunday),DATEPART(DW,@Munday), @@DATEFIRST
Can you see the behavior ?
The results are hidden here (select the text and you will see them)
DATEFIRST___Sunday_______Monday
1___________7___________1
2___________6___________7
3___________5___________6
4___________4___________5
5___________3___________4
6___________2___________3
7___________1___________2
assuming you did the exercise above yourself, then you can now think now what is the filter that you need...
You can use a filter on those two parameters together using "where DATEPART... and @@DATEFIRST...) or using one combine check. Can you think how?
Notice that this value is always 2 on Monday! Regarding our setting
(DATEPART(DW,@CurrentDate) + @@DATEFIRST) % 7
Please Don't Go Down Before YOu Understand!
Now we can go to the solution
* I really hope that you read all and did the small exercise yourself! You can not become a developer by copy answers, and this is the reason that from the start I only gave you tha way and not the final query!
DECLARE @CurrentDate DATE = '2007-08-20' -- This is only for testing since you should use the function GETDATE() instead
DECLARE @MinDateToFilter DATE
SET @MinDateToFilter = CASE
WHEN ((DATEPART(DW,@CurrentDate) + @@DATEFIRST) % 7) = 2 THEN DATEADD(DAY,-4,@CurrentDate)
ELSE DATEADD(DAY,-1,@CurrentDate)
END
SELECT *
FROM sales.salesOrderHeader
WHERE orderDate > @MinDateToFilter
I hope this was useful :-)
[Personal Site] [Blog] [Facebook] -
How to write a query for AFTER DATE
Hello Experts,
I’m new to SQL and stuck on a query. How would you write SQL Code for the following query:
The HR Department wants to determine the names of all employees who were hired after Davies:
Thanks in advance.Hello,
You need to change to the table name you have in your schema and in this case its "employees". Don't hard code date in where clause you might have different requirement later ;)
SELECT *
FROM employees
WHERE hire_date > (SELECT hire_date
FROM employees
WHERE name = 'Davies');Regards -
create table test (
company varchar2(2),
order_number number(4),
item_id number(4),
quantity number(8),
item_desc varchar2(16)
insert into test values ('A',1001,1,10,'apple');
insert into test values ('A',1001,2,20,'banana');
insert into test values ('B',1002,2,50,'banana');
insert into test values ('B',1002,1,30,'orange');
commit;
Table Test DATA
company order_number item_id quantity item_desc
1001 1 10 apple
A 10
1002 2 50 banana
1002 1 30 orange
B 80
90
how to make above result in using sql query ?
thanks !And just so you can see....
We can also get the totals and even break down the cursors to show individual orders within each of the companys...
SQL> select * from test;
CO ORDER_NUMBER ITEM_ID QUANTITY ITEM_DESC
A 1001 1 10 apple
B 1002 2 50 banana
B 1002 1 30 orange
B 1003 2 40 pear
B 1003 1 70 grapefruit
SQL>
SQL> select cursor(
2 select cursor(select cursor(select item_id, quantity, item_desc
3 from test t4
4 where t4.order_number = t2.order_number
5 and t4.company = t2.company
6 order by item_id) order_details,
7 order_number,
8 (select sum(quantity)
9 from test t5
10 where t5.company = t2.company
11 and t5.order_number = t2.order_number) order_quantity_total
12 from (select distinct company, order_number from test) t2
13 where t2.company = t.company
14 order by order_number) company_orders
15 ,RPAD(company,10,' ') company
16 ,(select sum(quantity)
17 from test t3
18 where t3.company = t.company) company_quantity
19 from (select distinct company from test) t
20 ) company_orders,
21 (select sum(quantity) from test) as total_quantity
22 from dual;
COMPANY_ORDERS TOTAL_QUANTITY
CURSOR STATEMENT : 1 200
CURSOR STATEMENT : 1
COMPANY_ORDERS COMPANY COMPANY_QUANTITY
CURSOR STATEMENT : 1 A 10
CURSOR STATEMENT : 1
ORDER_DETAILS ORDER_NUMBER ORDER_QUANTITY_TOTAL
CURSOR STATEMENT : 1 1001 10
CURSOR STATEMENT : 1
ITEM_ID QUANTITY ITEM_DESC
1 10 apple
CURSOR STATEMENT : 1 B 190
CURSOR STATEMENT : 1
ORDER_DETAILS ORDER_NUMBER ORDER_QUANTITY_TOTAL
CURSOR STATEMENT : 1 1002 80
CURSOR STATEMENT : 1
ITEM_ID QUANTITY ITEM_DESC
1 30 orange
2 50 banana
CURSOR STATEMENT : 1 1003 110
CURSOR STATEMENT : 1
ITEM_ID QUANTITY ITEM_DESC
1 70 grapefruit
2 40 pear
SQL> -
How to write sql query that display comma suppurated result using Group by
Hi,
I am having data like bellow ,
Above result got from joining two tables VMTAGroupClient,VMTAipNames .
Query i have written to display above result is,
select vgc.VMTAGroupId,vn.VMTAName from VMTAGroupClient vgc inner join VMTAipNames vn
on vgc.VMTAID=vn.VMTANameID group by vgc.VMTAGroupId,vn.VMTAName
using the VMTAGroupId column how to write query to display result result like,
VMTAGroupID VMTAs
1 VMTA1,VMTA3
2 VMTA2,VMTA4,VMTA5
Regards,
Anwar ShaikSatheesh,
Here in my case data need to read from two tables VMTAGroupClient, VMTAipNames.
VMTAGroupId is in one table and VMTAName column in some other table.Iin both the tables VMTAID is common.
Please check the above result displayed data from two tables.
can we write same query using join?
Anwar Shaik -
How to write a query for this data??
In this table i have column dob which is DATE type,for example 12-jan-89 I want output like this
Year Day
12-jan-89 Thusrs_day
12-jan-90 Friday
upto
12-jan-14 sundaykrishnagopi wrote:
No not like that ,I want up to 2014 year
Ok, so lets say you have table like this
SQL> create table my_table(dob date);
Table created.
SQL> insert into my_table (dob) values( to_date('12-jan-1989', 'dd-mon-yyyy'));
1 row created.
SQL> commit;
Commit complete.
SQL> select * from my_table;
DOB
12-JAN-89
You can write a query like this
select dob + (level -1) dob
, to_char(dob + (level -1), 'fmDay') day_
from my_table
connect
by level <= (dob + interval '25' year) - dob + 1; -
How to write sql query to parse xml?
Hi, I am new to this parsing xml. I need to extract value from xml using sql query. Please find the sample xml file. Kindly help me.
<?xml version="1.0" encoding="UTF-8"?>
<MaterialUpdates>
<Materials>
<SalesOrg>
<ID>KAR12</ID>
</SalesOrg>
</Materials>
</MaterialUpdates>
I need to extratct ID value : /MaterialUpdates/Materials/SalesOrg/IDThanks once again, it is working as per your suggestion. One last question .. how about in case of there is multiple nodes.
Please find sample xml below:
<?xml version="1.0" encoding="UTF-8"?>
<MaterialUpdates>
<Materials>
<SalesOrg>
<ID>KAR12</ID>
</SalesOrg>
<SalesOrg>
<ID>KAR13</ID>
</SalesOrg>
<SalesOrg>
<ID>KAR14</ID>
</SalesOrg>
</Materials>
</MaterialUpdates>
The above mentioned sql query works fine when there is one occurance of SalesOrg - ID, but fails when there is multiple occurance. -
How to write sql query for below example.
Hi,
I have requirement.
There are number of rows and I need the result through query as follows.Please help me to proved sql query for below mentioned requirement.
example: table TEST.
COLA COLB COLC COLD
MANAGER 5 NULL null
SR.MANAGE 6 3 NULL
VP 5 5 4
I have to write the sql query if COLA IS MANAGER THEN CONSIDER MANGER RECORD,AND IF ANY COLUMN FILED IS NULL FOR MANGER THEN CONSIDER COLA IS SR.MANGER, AND IF ANY COLUMN FILED IS NULL FOR SR,MANGER THEN CONSIDER VP records.
I need output as below.
COLB COLC COLD
5(MANGER) 3(sr.manger) 5(vp)
Please provide the for above mentioned output.
Thanks<<if COLA IS MANAGER THEN CONSIDER MANGER RECORD>>
What does this sentence means? COLA does not cnatin a single record but the number of records with diffrent values.
Regards
Arun
Maybe you are looking for
-
Hello, i am not sure of this is the right category to post this, but there are just so much categories and i cant find one that exactly matches what i was looking for. Anyway, I work for Si-Systems in the netherlands and one of our clients has a prob
-
Php-5.3.4-2 no longer has pdo.so moudle, is this ok?
Hello, I updated my php from php-5.3.4-1-i686.pkg.tar.xz to php-5.3.4-2-i686.pkg.tar.xz after words I started getting warnings about not being able to find pdo.so. Is this ok? Should I do anything about it? I may not need it at all, but I thought I h
-
I wrote an application that generates pdf files, and then the user can review theall of the files from an administration menu. In some instances, users may want to print out all of the pdf files at once instead of clicking each file then hitting prin
-
Can anyone please tell me: The legal syntax for inserting data into a user defined Object Type. Is it possible, in the declaration, to set each individual field of the Type to NULL? And then, do a SELECT...INTO to move data into those fields? E.G. De
-
"opaque" for variable type in debugger
I am debugging a database package body. I see some variables listed with a type of "opaque". What does that mean? Mike