Reg. Area Age <=19 20 <= Age <= 24 25 <=Age <= 29 Total No. of Voters
xxxx 10 15 7 32
yyyy 5 7 3 15
I have work out a script but the age is not in a range
select *
FROM (select rgs_id_reg_area,
count(decode(fbd_age,19,fbd_age)) Age19,
count(decode(fbd_age,20,fbd_age)) Age20
FROM rubyvoterstat where vote ='Y'
GROUP by rgs_id_reg_area)
order by rgs_id_reg_area
I have a table which contains two columns containing the range of some products. These range are alphanumeric and i want to calculate the count of this range by a query. .
test case: CREATE TABLE MARRIAGE_FILE_NAME ( START_SERIAL_NO VARCHAR2(10 BYTE) NOT NULL, END_SERIAL_NO VARCHAR2(10 BYTE) NOT NULL, CATCODE VARCHAR2(10 BYTE) NOT NULL,
We have a table with timestamp column and having millions of records.We want to create a materialized view or query, which can give count based
-on some group by columns from table and -group by on condition (if count > 1000) and -group by on condition (if timestamp range for that group is > 1hr)
difference between count(1) and count(*). As i know count(*) will give number of rows irrespective of null and count(1) will not count the null.My Oracle version is 10 g.
SQL> select * from t1;
A B C ---------- -------------------- -------------------- 1 2 3 2 5
SQL> select rownum,a.* from t1 a;
ROWNUM A B C ---------- ---------- -------------------- -------------------- 1 1 2 3 2 2 3 5 4 [code]....
I'm using this code, and it performs fine, but I'm wondering if there is a more elegant way to do it--maybe with "ROLLBACK". Basically (as you can see) I need to get a normal count for each group but also for each group take a percentage of the total count (so all groups pct adds up to 100 (oh yeah, don't test for zero below, but just a test... )
select c.Event, c.code, count(1) as calls, total.total_count, count(1) / total.total_count * 100 as pct_of_total from table1 c
[Code]....
[Edit MC: add code tags, do it yourself next time]
1) Alter table STS.DNA_ACCESSION add PARTITION DNA_ACC_P143 VALUES LESS THAN (286000000); ORA-14074: partition bound must collate higher than that of the last partition
2) ALTER TABLE STS_RO.DNA_ACCESSION SPLIT PARTITION DNA_ACC_P999 AT VALUES LESS THAN (286000000) INTO (PARTITION DNA_ACC_P143,
I have table :TABLE_X and want to select some data locate into specific range of Day/Month. But so far i couldn't find out the way to.
For example, i want to select people born within specific range of date(range : sysdate to (sysdate+7months ahead) Year here should not be consider, only the day and month.
e.g. a range could be from today:Sept,20 to Apr,18.
so what i was trying is to select doing the following.
select TABLE_X_ID, TABLE_X_BIRTH_DATE from TABLE_X where to_date(TABLE_X_BIRTH_DATE, 'DD/MM') between to_date (to_char(SYSDATE, 'DD/MM'), 'DD/MM') and to_date (to_char(SYSDATE+210, 'DD/MM'), 'DD/MM')
first am not sure if BETWEEN & AND will work for this case, bt it was the most logical way i could think about to get such range.
I am trying to create a SQL query which will check that various postcode formats are valid, but I am having trouble getting oracle sql to check for values within ranges - for example the following returns no rows, even though most of the postcodes I am dealing with start with 'P'.
select postcode from mytable.addresses where postcode like '[N-R]%' ;
This data needs to be represented in a SQL report as below. The Date Range in the below i.e., Starts with FEB, by checking against the sysdate.. That is from sysdate it will display the Quarter data for 4 months as below.
Currently I am using a procedural logic to populate data into a different table in the above format. Is there any method to do with a single SQL using PIVOT. Below given is the table structure and Insert scripts.
I have a table and want to calculate the stdev of a parameter over a rolling window (past 250 records, sorted by ID): ... stddev(parameter) over (order by ID range between 250 preceding and current row) as SD ...
I don't get any error, but if I calculate the same in excel (=STDEV(250 row range)), it seems that this code does not the same. Is there something wrong with the 250 row rolling window?
I have a field called percentage , where user doesnt want to enter any data , instead he wants a poplist like 0-100 when he clik the range will come as 0-10,10-20 and so on like 90-100 how i can do it he will increase and decrease it.
I want my user to be restricted for entering duplicate time within two times.
create table asd(dt_frm date,dt_to date);
insert into asd VALUES(to_date('01-04-2012 08:00','dd-mm-yyyy hh24:mi'),to_date('01-04-2012 10:00','dd-mm-yyyy hh24:mi')); insert into asd VALUES(to_date('01-04-2012 09:00','dd-mm-yyyy hh24:mi'),to_date('01-04-2012 11:00','dd-mm-yyyy hh24:mi'));
now in the second insertion I want to alert the entry user that 9am already falls in the saved record which is 8am to 10am and so that this record can't be saved.
I have a table partitioned by Range and subparitioned by hash.
i am issuing the following query .Bcos of security purposes i cannot post the full query.
Select <most of the columns> FROM qosTesthr PARTITION(PARTITION_ON_2011_11_17) WHERE starttime BETWEEN to_date('1111170000', 'yymmddHH24mi') AND to_date('1111172359', 'yymmddHH24mi')
Performance while using the index is very very slow.Is there any way without using the index and just the partition full scan can be forced by using some hint..
write the query for the following requirement.I need to generate the records for the range (Difference between From_val & to_val) ) for each ID
create table test_base(id varchar2(20) , from_val number , to_val number);
insert all into test_base values ('A', 6,10) into test_base values ('B', 22,30) into test_base values ('C', 123,130) into test_base values ('D', 852,860) into test_base values ('E', 30 ,30) select * from dual ; [code]....
No need to generate any thing for E as the difference is equal to Zero
I am creating a table where ID is an integer and the where clause will always be in range(for e.g between 200 and 400).
for best performance which index can i create on table such that query runs faster ?(a)clustered(b)non-clustered(c)unique(d)both clustered and non clustered
I need to pick a value based on range like if the range is as below
[code] if value =2000 then its 2000 elsif value >=2001 and value <=2499 it should be 2000 elsif value =2500 then 2500 elsif value >=2501 and value <=2999 it should be 2500 elsif value = 3000 then it should be 3000 [code]
Like this i need to pick a value by hardcoding this range and this look cumbersome in my program , is there a simple way to substitute this entire thing by passing one single value and getting one single value using a command or builtin.
I am trying to run copy command to copy data from one database to other.I 'm getting this error while running copy command. "ORA-01727: numeric precision specifier is out of range (1 to 38)"