Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

need help with query
Hi,

I have a table with composite key: ID1 and ID2 and it also has a
priority field.

I want to get all the information for all records with the minimum
priority group by ID2.  How can I achieve that?

Thanks.

Donna


Report this thread to moderator Post Follow-up to this message
Old Post
Donna
08-23-05 02:23 PM


Re: need help with query
Post table structures, sample data and the result you want

Madhivanan


Report this thread to moderator Post Follow-up to this message
Old Post
Madhivanan
08-23-05 02:23 PM


Re: need help with query
specifically when I do the following, I lose id2:

select min(priority) as priority, id1 from table t
group by id1

I want it to return id1, id2, priority where it is the min(priority)
group by id1


Report this thread to moderator Post Follow-up to this message
Old Post
Donna
08-23-05 04:24 PM


Re: need help with query
Try this

Select T1.id1,T1.id2,T2.priority from tablet T1
inner join (select min(priority) as priority, id1 from table t
group by id1 ) T2 on t1.id=T2.id and t1.id2=T2.id2

Madhivanan


Report this thread to moderator Post Follow-up to this message
Old Post
Madhivanan
08-23-05 04:24 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 12:08 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006