To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Related Sites > SQL Course

SQL Course SQL Course > Ask questions about the lessons on SQL Course 1 and 2. If you have problems > with the interface, please post in the Feedback forum

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 12-26-2002, 05:24 PM
faiyth faiyth is offline
Registered User
 
Join Date: Dec 2002
Posts: 3
DIstinct Select Problems

I am currently trying to display a list of emergencies that have happened. So that the user can either send one up as an alert, unalert it or edit it. For legal purposes they cannot delete any of the emergencies they enter.

Here's my data:
isemgid - emergency - isemgevent
1000 - FALSE - Emergency1
1001 - FALSE - Emergency1
1002 - FALSE - Emergency2
1003 - FALSE - Emergency3

I have two pages. alert.jsp and home.jsp.

home.jsp looks at the first field (1000) in the table and displays isemgevent if emergency is TRUE. (it only reads the first field as I only want one emergency displaying at a time).

alert.jsp is a list of all the emergencies available to choose from. When the user clicks on say, emergency2, it takes all of emergency2's data and moves it into the first field (1000) and sets emergency to TRUE. This then alerts the homepage to display this emergency instead of whatever was in 1000 before.
My problem is that 1000 and whatever field was just sent as an alert are the same except for their isemgid number. I only want to display the distinct fields. I can't delete the duplicate because if the user was to make emergency3 the alert, emergency2's information would be lost forever, and they need to be able to switch back.

This is what I want to display:
isemgid - emergency - isemgevent
1000 - FALSE - Emergency1
1002 - FALSE - Emergency2
1003 - FALSE - Emergency3

See how 1001 is missing? Now say they alert 1002 (emergency2) I want it to look like this:

isemgid - emergency - isemgevent
1000 - FALSE - Emergency2
1001 - FALSE - Emergency1
1003 - FALSE - Emergency3

So that whatever is duplicate doesn't show.
Reply With Quote
  #2  
Old 01-21-2003, 05:18 PM
skarasik skarasik is offline
Junior Member
 
Join Date: Jan 2003
Posts: 8
Lightbulb

Try this

select min(isemgid) as FirstID, emergency , isemgevent
from YOURTABLE
group by emergency, isemgevent
Reply With Quote
Reply Post New Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:36 PM.


DatabaseJournal Recent Articles


 » Grouping with SQL Server 2008

 » Conducting Service Broker Conversation Usi...

 » SQL Server Consolidation Initiative Under ...

 » Transaction Log Growth, do you need it?

 » New FileMaker Pro 10 Ships With Sleek New ...

Search Database Journal:
 





Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.