- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Sql Query
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 12:55 AM
тАО07-19-2004 12:55 AM
Sql Query
I have one small query. My query is like below:
"Display all columns from table1 for the uniq(column1) which has more than one column6"
That means there are some records in the table where for the same column query there should be one record but wrongly there is not. For that i want to extract those records which has more than one column6 for the same column1.
Rgds
Tapas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 12:36 PM
тАО07-19-2004 12:36 PM
Re: Sql Query
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 01:46 PM
тАО07-19-2004 01:46 PM
Re: Sql Query
From you query I understand that you have someting like this.
For example a table has two columns, column1 and column6. For same value of column1 you have multiple entries of column6.
The following sql will list the value of column1 and the number of column6 values associated with the same value of column1.
Here are the values in emp table
column1 column6
---------- ----------
101 AAAAAAA
101 SSSSSSS
101 BBBBBBB
102 xxxxxxxx
103 mmmmm
select count(1), column1
from emp
having count(1) > 1
group by column1;
COUNT(1) ENO
---------- ----------
3 101
2 102
I hope this helps.
Indira A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 04:06 PM
тАО07-19-2004 04:06 PM
Re: Sql Query
i tried the following simple example:
============================================
yd@MYDB.MU> select * from tab1;
C
_
b
c
a
Elapsed: 00:00:00.00
yd@MYDB.MU> select * from tab2;
C
_
a
a
a
a
a
b
b
c
8 rows selected.
Elapsed: 00:00:00.01
yd@MYDB.MU> select *
from tab1
where column1 in (select column6 from tab2 where column6=column1 having count(*) > 1
group by column6);
C
_
b
a
Elapsed: 00:00:00.01
yd@MYDB.MU>
============================================
let us know it this helps!
regards
Yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 06:30 PM
тАО07-19-2004 06:30 PM
Re: Sql Query
I am sorry that your sql didn't work. May be i have clearly stated you.
Below is the sample output. I hope it will clear your doubt.
If you see you will find that for tstAB=4839530267 there are two records. I want those records seperately. How can i get? Waiting for your feedback.
Rgds
Tapas
tstkey 44964913
tstAB 5637791967
tstacct 159392515
tstsndr
tstshpr ABC
tstscity
tstsstt
tstscnty
tstszip 3240505
tststel 022-22303949
tstattn
tstcnsg bcd
tstcadr1 Addr1
tstcadr2 addr2
tstccity
tstcstt
tstccnty
tstczip 900001
tstctel 011912222303949
tstorig X
tstdest Y
tstori_sub
tstloc_prod
tstgbl_prod A
tstpcs 1
tstwght 1.4
tstwgtu K
tstdwght 0.0
tstdtawb
tstdtpu 05/01/2004
tsttmpu 19:25
tstisogmtpu 800
tstdtky
tsttmky 19:25
tstisogmtky 800
tstrte
tstbill
tstfrom F@XAL
tstvsn 21
tstssndx
tstcsndx
tstdtmadd 1083466422
tstdtmfl 1083464753
tstkey 45482954
tstAB 4839530267
tstacct 121235539
tstsndr MR. X
tstshpr A.P LIBRARY
tstscity
tstsstt
tstscnty
tstszip 9700002
tststel 12122699
tstattn NA
tstcnsg XYZ
tstcadr1 AB Park
tstcadr2 AREA1
tstccity READING
tstcstt
tstccnty
tstczip UY154 4ZZ
tstctel 1235866600
tstorig CHK
tstdest RED
tstori_sub MAL
tstloc_prod X
tstgbl_prod O
tstpcs 1
tstwght 0.5
tstwgtu K
tstdwght 0.0
tstdtawb
tstdtpu 06/03/2004
tsttmpu 19:05
tstisogmtpu -530
tstdtky 06/03/2004
tsttmky 19:08
tstisogmtky -530
tstrte PL18C
tstbill 000000000
tstfrom LSM@CHK
tstvsn 15021
tstssndx
tstcsndx
tstdtmadd 1086278916
tstdtmfl 1086278554
tstkey 45488682
tstAB 4839530267
tstacct 121235539
tstsndr MR. X
tstshpr A.P LIBRARY
tstscity
tstsstt
tstscnty
tstszip 9700002
tststel 12122699
tstattn NA
tstcnsg XYZ
tstcadr1 AB Park
tstcadr2 AREA1
tstccity READING
tstcstt
tstccnty
tstczip UY154 4ZZ
tstctel 1235866600
tstorig CHK
tstdest RED
tstori_sub MAL
tstloc_prod X
tstgbl_prod O
tstpcs 1
tstwght 1.0
tstwgtu K
tstdwght 0.0
tstdtawb
tstdtpu 06/03/2004
tsttmpu 19:05
tstisogmtpu -530
tstdtky 06/03/2004
tsttmky 19:08
tstisogmtky -530
tstrte PL18C
tstbill 000000000
tstfrom LSM@CHK
tstvsn 15021
tstssndx
tstcsndx
tstdtmadd 1086288799
tstdtmfl 1086288406
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 06:43 PM
тАО07-19-2004 06:43 PM
Re: Sql Query
select * from table1
where column1 exists
(select count(*)
from table1 group by column6
having count(*) > 1);
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 07:00 PM
тАО07-19-2004 07:00 PM
Re: Sql Query
No, it is not working. It is giving syntax error on exists.
Rgds
Tapas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 07:20 PM
тАО07-19-2004 07:20 PM
Re: Sql Query
select * from employees
where department_id in
(select department_id
from employees group by department_id
having count(*) > 1);
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 09:22 PM
тАО07-19-2004 09:22 PM
Re: Sql Query
Thanx a lot.
Your sql is closing to solution. But i think i need to clarify exactly what i need( i think i have not given clear picture). If you see my example you will find that for the same tstAB(4839530267) there are two tstwght fields. I want those records which have diffrent tstwght fields.
(That means my question is like: Display those records which has different tstwght for the same tstAB fileds)
Is it clear to you or you need more..?
Rgds
Tapas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2004 10:21 PM
тАО07-19-2004 10:21 PM
Re: Sql Query
select * from employees
where department_id in
(select department_id
from employees group by department_id
having count(*) > 1)
and column2 <> column3;
Just check and try it.
sks