SQL & PL/SQL :: Validation Of PAN Number In Query?

Jun 5, 2013

create TABLE pan_number(pan CHAR(10) NOT NULL);
INSERT INTO pan_number(pan) VALUES('ABCDE1234A');
INSERT INTO pan_number(pan) VALUES('FGHIG5678F');
INSERT INTO pan_number(pan) VALUES('ABCDE12345');
INSERT INTO pan_number(pan) VALUES('ABCD1234A');
select * from pan_number;

now i need to validate valid PAN number which is of " The first 5 letters should be alphabets & last letter as alphabet & total length of PAN no. should be 10 digit"

i need to display valid PAN number , only first two rows are valid PAN numbers.

View 12 Replies


ADVERTISEMENT

SQL & PL/SQL :: How To Generate Number (not Sequence Number) In Query

Mar 9, 2011

I have the following select query that works perfectly fine. Returns 25 rows based on the descending order of the price.But, I want add one more expression to this list of columns in this query (apart from customer_id).

the expression should look like Cust-01 for the first customer from the below query all the way to Cust-25 for the last customer.But how can I can generate 01 to 25 in oracle?

select customer_id from
(select customer_id from capitalPLAN
where member_status = 'MEMBER' AND customer_id NOT in ('156','201','1385','2125','3906','165')
order by price desc
)
where rownum <= 25

View 4 Replies View Related

How To Print Sql Query With Serial Number

Mar 27, 2007

How can i print serial no of records in sql query? I know I can achieve this with selecting rownum but it gives wrong data if used with group by like below

select rownum,deptid from emp group by rownum,deptid order by rwnum

View 2 Replies View Related

Query To Know Number Of Columns In A Table?

Apr 4, 2008

query to know number of columns in a table i.e.

if I want to know how many number of colums are present in a specific table then what would be the query.

View 1 Replies View Related

Select Number Of Rows From Query?

Jun 13, 2007

In sql plus How do I get the number of distinct rows of a certain value?

for example

select group_number from records group by group_number

How would I query for the total number of group_numbers in this query?

View 2 Replies View Related

SQL & PL/SQL :: Query To Get Sequence Number In Group

Dec 7, 2010

I have Table Data in format :-

--------------------------
ABC
ABC
ABC
XYZ
XYZ

and i have a requirement where I need the output in this format.

-------------
ABC 1
ABC 2
ABC 3
XYZ 1
XYZ 2

what query to be used for this

View 2 Replies View Related

SQL & PL/SQL :: Query To Find The Number Of Alphabets?

Apr 20, 2013

I need to find out that assume i have a table having 2 column

Num Name
1 Adam
2 Akanksha
1 barren
2 bosli
3 Benergee
4 Bhawna
3 anjani

I want a query as if A is there 2 times then there should be 1 then 2 then there is b coming in 4 places then it should be 1 2 3 4 and again there is anjani so 3 should be there as 1 and 2 in first 2 places and the num should be automatically generated number based on the count of the alphabets

View 6 Replies View Related

SQL & PL/SQL :: Get Port Number In Database With Query?

Mar 5, 2010

How to get a port number in database with a sql query.

View 10 Replies View Related

Oracle - SQL Query For Number Of Days Since Last Backup

Oct 20, 2011

Is there any Oracle query I can run to determine the "number of days since the last backup"? SQL Server provides this data but I cant seem to find the equivalent for Oracle. Looks like there may be some information like this via RMAN tables and if so I want to create the simplest query possible to obtain that information.

View 3 Replies View Related

SQL & PL/SQL :: Query To Find Number Of Nulls For Each Record

Aug 18, 2013

We have data as below in the table. I need the to display the records in the order based on number of NULL values and position for each record.

provide a simple query using case in ORDER BY clause.

ID CLASS NAME DIST_ID DIST_NAME
0 NULL KIRAN 0 AP
0 C1213 NULL 0 AP
0 NULL NULL 0 AP
NULL C1234 NULL 0 AP
0 NULL NULL 0 AP
NULL NULL NULL NULL NULL
0 C123 RAJESH 0 AP
NULL C123 RAVI NULL AP

We have to give the rank based on NULL values and NULL value column position.Let us assume column positions as

1 2 3 4 5
ID CLASS NAME DIST_ID DIST_NAME

for the following three records number of NULL values are same. but positions are different.

0 NULL NULL 0 AP
NULL C1234 NULL 0 AP
0 NULL NULL 0 AP
NULL C123 RAVI NULL AP

Based on the column positions the ranks as
2*2+3*3=13
1*1+3*3=10
2*2+3*3=13
1*1+4*4=17

Which is having high rank (greatest number) that record should come last . The record which is having all values that should come first. The record which is having all NULL values should come last. The out put I want as

ID CLASS NAME DIST_ID DIST_NAME
0 C123 RAJESH 0 AP
0 NULL KIRAN 0 AP
0 C1213 NULL 0 AP
NULL C1234 NULL 0 AP
0 NULL NULL 0 AP
0 NULL NULL 0 AP
NULL C123 RAVI NULL AP
NULL NULL NULL NULL NULL

View 15 Replies View Related

SQL & PL/SQL :: Get Total Number Of Rows Returned By Query?

Sep 17, 2010

DECLARE
l_query VARCHAR2(4000);
TYPE cursor_type IS REF CURSOR;

[Code].....

How can I get the total number of rows returned by the query?

I want to be able to check omething like c1.ROWS = 0

View 4 Replies View Related

SQL & PL/SQL :: Query Two Columns With Datatypes As Number And Varchar

Jul 17, 2012

Have table with two columns with datatypes as number and varchar and the values in A column like 1,2,3 AND B column values like a,b,c. Now need to display data in a single column as 1,a,2,b,3,c.

View 4 Replies View Related

SQL & PL/SQL :: How To Pass Different Number Of Columns Dynamically To A Query

Apr 26, 2010

I want to pass Number of columns dynamically to a query. I got success in SQL.

SQL> select &column_list from emp;
Enter value for column_list: empno,ename,sal

EMPNO ENAME SAL
---------- ---------- ----------
7369 SMITH 800
7499 ALLEN 1600
7521 WARD 1250
7566 JONES 2975
7654 MARTIN 1250
7698 BLAKE 2850
7782 CLARK 2450
7788 SCOTT 3000
7839 KING 5000
7844 TURNER 1500
7876 ADAMS 1100
7900 JAMES 950
7902 FORD 3000
7934 MILLER 1300

14 rows selected.

But the same i need to achieve in pl/sql. I try with the Ref cursor, but not succeeded.

View 15 Replies View Related

SQL & PL/SQL :: Query To Add Total Number Of Count Of Each Table

Jun 13, 2011

I want to know that whether we can write a query to add total number of count of each table.

for example:

select count(*) from emp;

count(*)
14

select count(*) from emp_1;

count(*)
15

select count(*) from emp_2;

count(*)
16

My question is that is it possible to add this all the three results and get the value as 45.

View 3 Replies View Related

SQL & PL/SQL :: How To Group Query Sequence Number Wise

Oct 3, 2010

I ve a data in table as follows

code status seqnce Length
B1 AVL 1 10
B2 AVL 2 10
B3 ASG 3 10
B4 AVL 4 10
B5 AVL 5 10
B6 AVL 6 10
B4 ASG 7 10
B4 ASG 8 10

I need to group the AVL status codes with the sum of lengths Ex) B1 to B2 - 20 B4 to B6 - 30 like that.

View 5 Replies View Related

SQL & PL/SQL :: Query To List Donor Number And Last Name Of Donors

Mar 7, 2010

SQL> select * from year;
YEAR YEARGOAL
1992 5000
1995 5000
1993 5000
1994 5500
[code]...

what would the query be toList the donor number and last name of donors who did not contribute in 1994, in order by donor number.

View 2 Replies View Related

SQL & PL/SQL :: Convert Number To Specific Format Using Query

Apr 14, 2011

I want to convert a number to this format using below query but i'm getting error. how to correct the below query.

SELECT TO_CHAR(12345678, '99G9999D99') FROM dual;

error:-###########

View 2 Replies View Related

PL/SQL :: Query To Find Number Of Days Across Each Month

Oct 1, 2012

We have a requirement where we need to pay allowance for the employees based on their number of working days. Say for example if an employee worked from 03/Mar/2012 to 05/Apr/2012.

We have a fixed value for per month 300 Dirhams. But the Number of Days on March s 31 and Number of days in April is 30. So per day allowance for March day would be 300/31 and April would be 300/30.

We are looking for logic opr query which calculates first eh number of days in each month ( across months) and then calculate as below

Number of Working days in March is 31 - 3 + 1 = 29

Allowance A1 = (300 * 29 )/31

Number of Working days in April is 5 ( this also needs to find logical I am guess )
Allowance A2 = (300 * 5 )/30

Then A1 + A2.

The A(n) would be the total allowance where provided the number of month across.

View 10 Replies View Related

SQL & PL/SQL :: Write A Single Query Showing Number Of Requests

Jan 15, 2011

I need to write a single query showing the number of requests (job_no) in my organization sections (1A,3A,4C,9Z....etc) based on these conditions..Less than 2 months & between 2 and 6 & between 6 and 12month & more than 12 months in my organization sections.

--Table structure

SQL> desc job_transfer
Name
----------------------
JOB_NO (Request number)
IN_SECT (name of entered section)
IN_DATE (date entered the section)
OUT_SECT
OUT_DATE (date went out from section)

I tried using UNION ALL but it didnt work fine.

View 3 Replies View Related

SQL & PL/SQL :: Query That Shows Each Building Code / Name And Number Of Rooms

Mar 13, 2013

I have been trying to figure out how to write a query that shows each building code building name and number of rooms from a database with four tables : emp, build, room, roombook

View 9 Replies View Related

SQL & PL/SQL :: Query To Retrieve Number Of Not Null Rows For Each Column?

Jul 7, 2011

I need a generic query to generate total # of records for each table in a schema, total # of records that are not null for each column in the table, and total # of records that are null for each of those columns in those tables.

ex:

the output should look like this.

owner schema table_name total# recs in the table, column_name,
------ ------ ---------- ------------------------- -----------

# of records not null # of records null
---------------------- --------------------

View 12 Replies View Related

PL/SQL :: Write Dynamic SQL To Query Unknown Number Of Columns

Jun 6, 2012

I need to write a dynamic SQL in PL SQL to query an unknown number of columns. Let me take a simple example query here:

SELECT FIRST_NAME, LAST_NAME FROM VENDOR_CONTACTS

If I have known the number of columns, e.g. querying two columns: "FIRST_NAME" and "LAST_NAME", I can write a DYNAMIC SQL based on the template in table 8-2 of URL....

DECLARE
stmt_str varchar2(200);
cur_hdl int;
rows_processed int;
FIRST_NAME varchar2(200);
LAST_NAME varchar2(200);
BEGIN
cur_hdl := dbms_sql.open_cursor; -- open cursor
stmt_str := 'SELECT FIRST_NAME, LAST_NAME FROM VENDOR_CONTACTS';
[code]....

However, if I wish to write a dynamical sql to query these two columns for a more general purpose (which should meet the requirement to query different number of columns, e.g. three columns, FIRST_NAME, LAST_NAME, BIRTHDAY instead of two columns FIRST_NAME and LAST_NAME). To do this I first try to query the same two columns but using a different method, following URL.....My code for the same query has error, and I cannot solve it.

DECLARE
stmt_str varchar2(200);
cur_hdl int;
rows_processed int;
l_columns dbms_sql.desc_tab;
l_dummy NUMBER;
l_value NUMBER;
[code]....

View 7 Replies View Related

PL/SQL :: Number Range Query Causes Repeated Scan By Index

Oct 16, 2012

I have a query that seems to repeatedly call an index scan on a table for reasons I'm not sure about. Why it would be doing the index scan on totaldwellingarea in the dimensions table (DIMEN_PID_TDWELLAREA) repeatedly? This only seems to happen when I put on the range clause d.totaldwellingarea between scr.lowvalue and scr.highvalue.

I am using Oracle version 9.2.0.3.

select d.propertyid,d.totaldwellingarea, e.size_,  scr.size_
from  eqid e, dimensions d,  brt_eval.size_code_ranges scr
where e.style not in ('1','A','G','L') and e.size_  = '0'
and d.propertyid = e.propertyid and e.style = scr.style and d.totaldwellingarea between scr.lowvalue and  scr.highvalue;

CREATE
  TABLE "BRT_ADMIN"."EQID"
  (
    "PROPERTYID"   VARCHAR2(20 BYTE) NOT NULL ENABLE,
    "EQID"         CHAR(10 BYTE),
    "ZONE_"        CHAR(1 BYTE),
    "AREA"         CHAR(1 BYTE),
[code].....

View 3 Replies View Related

Query To List Employee Number And Amount Of Days Sick

Apr 19, 2009

I have been trying to construct a query in Oracle that allows me to do the following:

For example if I have the data below:

EmpNo DOB SickDays
Alex 445 15/06/1985 7
Tom 778 22/08/1981 4
James 992 07/10/1978 5

I need to write and a query to lists the employee number and the amount of days sick that they have had and also add a column that compares the number of sick days to the average number of suck days by ALL employees.

I can calculate the average sick days etc, but It wont see to allow me to find the difference between that and the amount of sick days that each person has had. I have tried this many ways and have not been able to come up with a solution.

View 3 Replies View Related

SQL & PL/SQL :: Query To Find Number Of Primary Keys Present In A Table?

May 17, 2011

is there any query to find number of primary keys present in a table.

View 13 Replies View Related

Create A Query That Displays Number Of Unique Logon For Each User Per Day?

Feb 23, 2010

I have a table that has three columns.
UserId - DateStamp - Action

An action contains user activities such as "logon". A user may logon multiple times in a day.I'm trying to create a query that displays the number of unique logons for each user per day.

By doing the following:

select userid, to_char(creationtimestamp,'YYYY-MM-DD'), count(*)
from useraction
where action = 'logon'
group by to_char(creationtimestamp,'YYYY-MM-DD'), userid
order by to_char(creationtimestamp,'YYYY-MM-DD') desc;

I can get the following results
userid - date - count
1 - 2/21/2010 - 8
1 - 2/22/2010 - 3
2 - 2/22/2010 - 2
1 - 2/23/2010 - 1
4 - 2/23/2010 - 6
6 - 2/23/2010 - 1

What I'm trying to get is
2/21/2010 - 1
2/22/2010 - 2
2/22/2010 - 3

View 2 Replies View Related

PL/SQL :: Query To Find First And Last Call Made By Selected Number For Date Range

Apr 27, 2013

create table call(id number(10) primary key,mobile_no number(10), other_no number(10), call_type varchar2(10),call_date_time date, duration number(10));

insert into call values(1,9818764535,9899875643,'IN','24-APR-13 02:10:43',10);
insert into call values(1,9818764535,9898324234,'IN','24-APR-13 05:06:78',10);
insert into call values(1,9818764535,9215468734,'IN','24-APR-13 15:06:78',10);
insert into call values(1,9818764535,9899875643,'OUT','25-APR-13 01:06:78',10);
insert into call values(1,9899875643,9899875643,,'OUT','25-APR-13 22:06:78',10);

Query : need to find first and last call of '9818764535' mobile number and of call_date between '24-apr-13' and '25-apr-13';

Result :

date ,mobile_no , other_no, call_type, duration
24/apr/13 , 9818764535,9899875643,'IN',10
24/apr/13 ,9818764535,9215468734,'IN',10

[Code]....

View 5 Replies View Related

Reports & Discoverer :: SQL Union All - Query Block Has Incorrect Number Of Result Columns

Feb 1, 2012

I have the following Union All query. It throws the following error in SQL plus

ERROR at line 27: ORA-01789: query block has incorrect number of result columns

After doing some google for the above error it suggests there are incorrect number of columns in the Union All query.I could not figure out the exact location well SQl Plus says error is on line 27 at the first opening bracket like

(Select distinct c.contact_code

Following is the SQL query

Select
tbl_contact.contact_code,
contact_title
||'.'||contact_name contact_name,
contact_address,
[Code] ......

View 1 Replies View Related

SQL & PL/SQL :: Regex Validation?

May 27, 2013

I have data stored in the format 01.01 , 01.02,02.03 in one field of table , i dont want my user to deviate from this coding by not typing like 0001.01 or anything othen than above format , how can i prevent this.

CREATE TABLE OM_AIC_SALES_CODES ( SALE_CODE VARCHAR2(6),SALE_DESC VARCHAR2(240),SALE_MIN_WT NUMBER, SALE_MAX_WT NUMBER)
insert into om_aic_sales_codes ( SALE_CODE ,SALE_DESC ,SALE_MIN_WT , SALE_MAX_WT ) values ('01.01','Extra Light <= 30 kg/m',NULL,NULL);
insert into om_aic_sales_codes ( SALE_CODE ,SALE_DESC ,SALE_MIN_WT , SALE_MAX_WT ) values ('01.02','Light >30 <=60 kg/m',NULL,NULL);

--i dont want the following inserts to happen or invalid inserts.

insert into om_aic_sales_codes ( SALE_CODE ,SALE_DESC ,SALE_MIN_WT , SALE_MAX_WT ) values ('01.003','Light >30 <=60 kg/m',NULL,NULL);
insert into om_aic_sales_codes ( SALE_CODE ,SALE_DESC ,SALE_MIN_WT , SALE_MAX_WT ) values ('001.003','Light >30 <=60 kg/m',NULL,NULL);
insert into om_aic_sales_codes ( SALE_CODE ,SALE_DESC ,SALE_MIN_WT , SALE_MAX_WT ) values ('0001','Light >30 <=60 kg/m',NULL,NULL);

View 6 Replies View Related

Forms :: Validation Using AM / PM?

Dec 19, 2010

I have two date fields in my form one start date and the other is end date.I have changed their properties to datetime and set the initial value $$dbdatetime$$ and format mask to dd/mm/rrrr 24HH:MM , what i want is

1.i want to display the A.M and P.M along with that.
2.If the time and date of end dt is lesser than start error must come.
3.If the user enters the P.M during the day time before noon then it should give error message.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved