Maximum length value in a table
I have a table and I´d like to know what is the maximum lengh value that exist on the field "phone_number" and email_address.
I want to know if there exist any value that was entered that is greater than the allowed.
This is my query:
SELECT
hp.party_name
, hca.account_number
, hca.cust_account_id
-- , hcsu.LOCATION customer_site_name
, hcas.cust_acct_site_id
, hcp.phone_number
, hcp.email_address
, hl.address1
, hl.address2
, hl.address3
, hl.address4
, hl.city
, hl.province
, hl.postal_code
, hcas.status
, DECODE( hcas.attribute5, 'PUP', 'Y', 'N' )
, hca.status
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTY_SITES'
AND contact_point_type IN ('EMAIL','PHONE')
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hca.account_number = ''
;
sql oracle
|
show 2 more comments
I have a table and I´d like to know what is the maximum lengh value that exist on the field "phone_number" and email_address.
I want to know if there exist any value that was entered that is greater than the allowed.
This is my query:
SELECT
hp.party_name
, hca.account_number
, hca.cust_account_id
-- , hcsu.LOCATION customer_site_name
, hcas.cust_acct_site_id
, hcp.phone_number
, hcp.email_address
, hl.address1
, hl.address2
, hl.address3
, hl.address4
, hl.city
, hl.province
, hl.postal_code
, hcas.status
, DECODE( hcas.attribute5, 'PUP', 'Y', 'N' )
, hca.status
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTY_SITES'
AND contact_point_type IN ('EMAIL','PHONE')
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hca.account_number = ''
;
sql oracle
Add some example data. What do the entries you are looking at look like, and what do you want them to look like?
– SandPiper
Jan 1 at 15:44
@SandPiper i want to know what is the maximum lengh value,i man, for example: if there exist one single field that contains 2 emails or 3 emails
– programming_amazing
Jan 1 at 15:53
1
Check out this below link: stackoverflow.com/questions/3361761/…
– saravanatn
Jan 1 at 16:05
1
How is the maximum allowed value defined? Ifhz_contact_points.phone_number
is defined asvarchar2(20)
, for example, then by definition no value can be longer than that, so I'm not sure which values you are looking for.
– William Robertson
Jan 1 at 16:09
"if there exist one single field that contains 2 emails or 3 emails" Eh? That's very different from finding the maximum length of a column. You probably need to post some sample data which illustrates the problem you're trying to solve.
– APC
Jan 1 at 16:32
|
show 2 more comments
I have a table and I´d like to know what is the maximum lengh value that exist on the field "phone_number" and email_address.
I want to know if there exist any value that was entered that is greater than the allowed.
This is my query:
SELECT
hp.party_name
, hca.account_number
, hca.cust_account_id
-- , hcsu.LOCATION customer_site_name
, hcas.cust_acct_site_id
, hcp.phone_number
, hcp.email_address
, hl.address1
, hl.address2
, hl.address3
, hl.address4
, hl.city
, hl.province
, hl.postal_code
, hcas.status
, DECODE( hcas.attribute5, 'PUP', 'Y', 'N' )
, hca.status
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTY_SITES'
AND contact_point_type IN ('EMAIL','PHONE')
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hca.account_number = ''
;
sql oracle
I have a table and I´d like to know what is the maximum lengh value that exist on the field "phone_number" and email_address.
I want to know if there exist any value that was entered that is greater than the allowed.
This is my query:
SELECT
hp.party_name
, hca.account_number
, hca.cust_account_id
-- , hcsu.LOCATION customer_site_name
, hcas.cust_acct_site_id
, hcp.phone_number
, hcp.email_address
, hl.address1
, hl.address2
, hl.address3
, hl.address4
, hl.city
, hl.province
, hl.postal_code
, hcas.status
, DECODE( hcas.attribute5, 'PUP', 'Y', 'N' )
, hca.status
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTY_SITES'
AND contact_point_type IN ('EMAIL','PHONE')
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hca.account_number = ''
;
sql oracle
sql oracle
edited Jan 1 at 15:43
SandPiper
2,17931730
2,17931730
asked Jan 1 at 15:39
programming_amazingprogramming_amazing
275
275
Add some example data. What do the entries you are looking at look like, and what do you want them to look like?
– SandPiper
Jan 1 at 15:44
@SandPiper i want to know what is the maximum lengh value,i man, for example: if there exist one single field that contains 2 emails or 3 emails
– programming_amazing
Jan 1 at 15:53
1
Check out this below link: stackoverflow.com/questions/3361761/…
– saravanatn
Jan 1 at 16:05
1
How is the maximum allowed value defined? Ifhz_contact_points.phone_number
is defined asvarchar2(20)
, for example, then by definition no value can be longer than that, so I'm not sure which values you are looking for.
– William Robertson
Jan 1 at 16:09
"if there exist one single field that contains 2 emails or 3 emails" Eh? That's very different from finding the maximum length of a column. You probably need to post some sample data which illustrates the problem you're trying to solve.
– APC
Jan 1 at 16:32
|
show 2 more comments
Add some example data. What do the entries you are looking at look like, and what do you want them to look like?
– SandPiper
Jan 1 at 15:44
@SandPiper i want to know what is the maximum lengh value,i man, for example: if there exist one single field that contains 2 emails or 3 emails
– programming_amazing
Jan 1 at 15:53
1
Check out this below link: stackoverflow.com/questions/3361761/…
– saravanatn
Jan 1 at 16:05
1
How is the maximum allowed value defined? Ifhz_contact_points.phone_number
is defined asvarchar2(20)
, for example, then by definition no value can be longer than that, so I'm not sure which values you are looking for.
– William Robertson
Jan 1 at 16:09
"if there exist one single field that contains 2 emails or 3 emails" Eh? That's very different from finding the maximum length of a column. You probably need to post some sample data which illustrates the problem you're trying to solve.
– APC
Jan 1 at 16:32
Add some example data. What do the entries you are looking at look like, and what do you want them to look like?
– SandPiper
Jan 1 at 15:44
Add some example data. What do the entries you are looking at look like, and what do you want them to look like?
– SandPiper
Jan 1 at 15:44
@SandPiper i want to know what is the maximum lengh value,i man, for example: if there exist one single field that contains 2 emails or 3 emails
– programming_amazing
Jan 1 at 15:53
@SandPiper i want to know what is the maximum lengh value,i man, for example: if there exist one single field that contains 2 emails or 3 emails
– programming_amazing
Jan 1 at 15:53
1
1
Check out this below link: stackoverflow.com/questions/3361761/…
– saravanatn
Jan 1 at 16:05
Check out this below link: stackoverflow.com/questions/3361761/…
– saravanatn
Jan 1 at 16:05
1
1
How is the maximum allowed value defined? If
hz_contact_points.phone_number
is defined as varchar2(20)
, for example, then by definition no value can be longer than that, so I'm not sure which values you are looking for.– William Robertson
Jan 1 at 16:09
How is the maximum allowed value defined? If
hz_contact_points.phone_number
is defined as varchar2(20)
, for example, then by definition no value can be longer than that, so I'm not sure which values you are looking for.– William Robertson
Jan 1 at 16:09
"if there exist one single field that contains 2 emails or 3 emails" Eh? That's very different from finding the maximum length of a column. You probably need to post some sample data which illustrates the problem you're trying to solve.
– APC
Jan 1 at 16:32
"if there exist one single field that contains 2 emails or 3 emails" Eh? That's very different from finding the maximum length of a column. You probably need to post some sample data which illustrates the problem you're trying to solve.
– APC
Jan 1 at 16:32
|
show 2 more comments
2 Answers
2
active
oldest
votes
The maximum length of a field(s):
SELECT MAX(LENGTH(email_address)), MAX(LENGTH(phone_number)) FROM hz_contact_points
No group by is needed because you're aggregating the whole set. Note that this tells you the longest data known (eg it will return 72) but it tells you nothing else. You would then have to query again to find rows where this length was the case:
SELECT *
FROM hz_contact_points
WHERE LENGTH(email_address) = 72
It might be easier to look at eg the top 10 rows ordered by email length descending:
SELECT * FROM (
SELECT *
FROM hz_contact_points
ORDER BY LENGTH(email_address) DESC
) a
WHERE rownum <= 10
(If you're on oracle12c+ you can do away with the outer query and write FETCH FIRST 10 ROWS ONLY
)
Rows that have more than one email address:
SELECT *
FROM hz_contact_points
WHERE email_address LIKE '%@%@%'
add a comment |
If you would like to find the rows that have the maximum field length in given field of a table, then try the following query.
SELECT *
FROM TABLE_NAME
WHERE LENGTH(FIELD_NAME) =
(
SELECT MAX(LENGTH(FIELD_NAME))
FROM TABLE_NAME
)
Thank you for replying. I tried your query but it is not working, take a look: imgur.com/a/zR1SoBa
– programming_amazing
Jan 2 at 0:00
@programming_amazing you are missing a closing bracket in MAX(LENGTH(FIELD_NAME))
– Waqas Shabbir
Jan 2 at 13:16
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53996744%2fmaximum-length-value-in-a-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The maximum length of a field(s):
SELECT MAX(LENGTH(email_address)), MAX(LENGTH(phone_number)) FROM hz_contact_points
No group by is needed because you're aggregating the whole set. Note that this tells you the longest data known (eg it will return 72) but it tells you nothing else. You would then have to query again to find rows where this length was the case:
SELECT *
FROM hz_contact_points
WHERE LENGTH(email_address) = 72
It might be easier to look at eg the top 10 rows ordered by email length descending:
SELECT * FROM (
SELECT *
FROM hz_contact_points
ORDER BY LENGTH(email_address) DESC
) a
WHERE rownum <= 10
(If you're on oracle12c+ you can do away with the outer query and write FETCH FIRST 10 ROWS ONLY
)
Rows that have more than one email address:
SELECT *
FROM hz_contact_points
WHERE email_address LIKE '%@%@%'
add a comment |
The maximum length of a field(s):
SELECT MAX(LENGTH(email_address)), MAX(LENGTH(phone_number)) FROM hz_contact_points
No group by is needed because you're aggregating the whole set. Note that this tells you the longest data known (eg it will return 72) but it tells you nothing else. You would then have to query again to find rows where this length was the case:
SELECT *
FROM hz_contact_points
WHERE LENGTH(email_address) = 72
It might be easier to look at eg the top 10 rows ordered by email length descending:
SELECT * FROM (
SELECT *
FROM hz_contact_points
ORDER BY LENGTH(email_address) DESC
) a
WHERE rownum <= 10
(If you're on oracle12c+ you can do away with the outer query and write FETCH FIRST 10 ROWS ONLY
)
Rows that have more than one email address:
SELECT *
FROM hz_contact_points
WHERE email_address LIKE '%@%@%'
add a comment |
The maximum length of a field(s):
SELECT MAX(LENGTH(email_address)), MAX(LENGTH(phone_number)) FROM hz_contact_points
No group by is needed because you're aggregating the whole set. Note that this tells you the longest data known (eg it will return 72) but it tells you nothing else. You would then have to query again to find rows where this length was the case:
SELECT *
FROM hz_contact_points
WHERE LENGTH(email_address) = 72
It might be easier to look at eg the top 10 rows ordered by email length descending:
SELECT * FROM (
SELECT *
FROM hz_contact_points
ORDER BY LENGTH(email_address) DESC
) a
WHERE rownum <= 10
(If you're on oracle12c+ you can do away with the outer query and write FETCH FIRST 10 ROWS ONLY
)
Rows that have more than one email address:
SELECT *
FROM hz_contact_points
WHERE email_address LIKE '%@%@%'
The maximum length of a field(s):
SELECT MAX(LENGTH(email_address)), MAX(LENGTH(phone_number)) FROM hz_contact_points
No group by is needed because you're aggregating the whole set. Note that this tells you the longest data known (eg it will return 72) but it tells you nothing else. You would then have to query again to find rows where this length was the case:
SELECT *
FROM hz_contact_points
WHERE LENGTH(email_address) = 72
It might be easier to look at eg the top 10 rows ordered by email length descending:
SELECT * FROM (
SELECT *
FROM hz_contact_points
ORDER BY LENGTH(email_address) DESC
) a
WHERE rownum <= 10
(If you're on oracle12c+ you can do away with the outer query and write FETCH FIRST 10 ROWS ONLY
)
Rows that have more than one email address:
SELECT *
FROM hz_contact_points
WHERE email_address LIKE '%@%@%'
edited Jan 1 at 16:49
answered Jan 1 at 16:44
Caius JardCaius Jard
12k21240
12k21240
add a comment |
add a comment |
If you would like to find the rows that have the maximum field length in given field of a table, then try the following query.
SELECT *
FROM TABLE_NAME
WHERE LENGTH(FIELD_NAME) =
(
SELECT MAX(LENGTH(FIELD_NAME))
FROM TABLE_NAME
)
Thank you for replying. I tried your query but it is not working, take a look: imgur.com/a/zR1SoBa
– programming_amazing
Jan 2 at 0:00
@programming_amazing you are missing a closing bracket in MAX(LENGTH(FIELD_NAME))
– Waqas Shabbir
Jan 2 at 13:16
add a comment |
If you would like to find the rows that have the maximum field length in given field of a table, then try the following query.
SELECT *
FROM TABLE_NAME
WHERE LENGTH(FIELD_NAME) =
(
SELECT MAX(LENGTH(FIELD_NAME))
FROM TABLE_NAME
)
Thank you for replying. I tried your query but it is not working, take a look: imgur.com/a/zR1SoBa
– programming_amazing
Jan 2 at 0:00
@programming_amazing you are missing a closing bracket in MAX(LENGTH(FIELD_NAME))
– Waqas Shabbir
Jan 2 at 13:16
add a comment |
If you would like to find the rows that have the maximum field length in given field of a table, then try the following query.
SELECT *
FROM TABLE_NAME
WHERE LENGTH(FIELD_NAME) =
(
SELECT MAX(LENGTH(FIELD_NAME))
FROM TABLE_NAME
)
If you would like to find the rows that have the maximum field length in given field of a table, then try the following query.
SELECT *
FROM TABLE_NAME
WHERE LENGTH(FIELD_NAME) =
(
SELECT MAX(LENGTH(FIELD_NAME))
FROM TABLE_NAME
)
answered Jan 1 at 17:08
Waqas ShabbirWaqas Shabbir
61811030
61811030
Thank you for replying. I tried your query but it is not working, take a look: imgur.com/a/zR1SoBa
– programming_amazing
Jan 2 at 0:00
@programming_amazing you are missing a closing bracket in MAX(LENGTH(FIELD_NAME))
– Waqas Shabbir
Jan 2 at 13:16
add a comment |
Thank you for replying. I tried your query but it is not working, take a look: imgur.com/a/zR1SoBa
– programming_amazing
Jan 2 at 0:00
@programming_amazing you are missing a closing bracket in MAX(LENGTH(FIELD_NAME))
– Waqas Shabbir
Jan 2 at 13:16
Thank you for replying. I tried your query but it is not working, take a look: imgur.com/a/zR1SoBa
– programming_amazing
Jan 2 at 0:00
Thank you for replying. I tried your query but it is not working, take a look: imgur.com/a/zR1SoBa
– programming_amazing
Jan 2 at 0:00
@programming_amazing you are missing a closing bracket in MAX(LENGTH(FIELD_NAME))
– Waqas Shabbir
Jan 2 at 13:16
@programming_amazing you are missing a closing bracket in MAX(LENGTH(FIELD_NAME))
– Waqas Shabbir
Jan 2 at 13:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53996744%2fmaximum-length-value-in-a-table%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Add some example data. What do the entries you are looking at look like, and what do you want them to look like?
– SandPiper
Jan 1 at 15:44
@SandPiper i want to know what is the maximum lengh value,i man, for example: if there exist one single field that contains 2 emails or 3 emails
– programming_amazing
Jan 1 at 15:53
1
Check out this below link: stackoverflow.com/questions/3361761/…
– saravanatn
Jan 1 at 16:05
1
How is the maximum allowed value defined? If
hz_contact_points.phone_number
is defined asvarchar2(20)
, for example, then by definition no value can be longer than that, so I'm not sure which values you are looking for.– William Robertson
Jan 1 at 16:09
"if there exist one single field that contains 2 emails or 3 emails" Eh? That's very different from finding the maximum length of a column. You probably need to post some sample data which illustrates the problem you're trying to solve.
– APC
Jan 1 at 16:32