Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
zrozerostang
Starting Member
3 Posts |
Posted - 2009-12-18 : 21:29:00
|
| Good Evening. I'm having some trouble. The problem i'm experiencing deals with the FDAYS.CLASS_NO = CLASSES.CLASS_NO portion of the WHERE statement. There are many instances where the two match so it's returning multiple rows for each entry. Is there a way I can nest a DISTINCT funtion somehow so it only returns one result? I only need one result per query. Any help would be greatly appreciated. Cheers :) SELECT CLASSES.STARTDATE, CLASSES.ENDDATE, CLASSES.CLASS_NO, CLASSES.SITE_NO, CLASSES.LOCATION, CLASSES.MAXSEATS, FDAYS.CLASS_NO, FACILITIES.FACILITY_NO, FACILITIES.NAMEFROM CLASSES, FDAYS, FACILITIES, WHERE COURSE_NO = :1 AND FDAYS.CLASS_NO = CLASSES.CLASS_NO AND ONLINEVIEWABLE = '1' AND FDAYS.FACILITY_NO = FACILITIES.FACILITY_NO and STARTDATE >= :DATE_2 AND STARTDATE <= :DATE_3 AND (ORG_NO = '' OR ORG_NO IS NULL OR ORG_NO IN <#4> ) ORDER BY STARTDATEUNIONSELECT DISTINCT CLASS_NO FROM FDAYS |
|
|
zrozerostang
Starting Member
3 Posts |
Posted - 2009-12-18 : 21:34:04
|
| My appologies. Please disregard Union and everything below it. I was trying something out. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-12-20 : 03:03:14
|
| what does FDAYS represent? can you show some sample data to determine the many to one relation? |
 |
|
|
zrozerostang
Starting Member
3 Posts |
Posted - 2009-12-21 : 12:20:24
|
| Thanks for your reply. The FDAYS table is the "Facility Days" table. It tells which facilities are booked on which days. This creates multiples rows retruned because some classes are multipe days. I only need one record from the FDAYS table per return. This way I can display online which facility the class is taking place. The reason I have to bring is the FDAYS table is because there is no direct link between CLASSES and FACILITIES (which is where the facility name comes from).I can e-mail you some sample data if you would like.Thanks in advance. |
 |
|
|
|
|
|
|
|