|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help!!!!
I have to try and get my head around this question and ive never seen sql this advanced before.please set me in the right direction.thanks in advance.
Using the meeting table schema below provide a SQL statement to create a view in Microsoft SQL Server that will return only 1 record displaying the contents of the MEETING_NUMBER field. The rules for the view are as follows: • The START_DATE field which contains the start date of the meeting record must contain a value before the current system date. • The START_DATE field must be the closest date to the current system date. ID int (4) DOC_CLASS varchar (30) DOC_NUMBER int (4) REVISION int (4) START_DATE datetime (8) FINISH_DATE datetime (8) MEET_TIME varchar (5) VENUE varchar (50) TYPE varchar (50) MEETING_NUMBER varchar (11) CUTOFF_PERIOD int (4) CUTOFF_TIME varchar (5) AGENDA_STATUS varchar (50) SUBJECT varchar (50) SPONSORING_MIN varchar (50) SUPP_AGENDA_STATUS varchar (50) Possible answer: select meeting_number from meeting where start_date < getdate() order by start_date desc |
|
#2
|
|||
|
|||
|
heres my attempt.No one in here seems to have a clue but u never know what pops into someones head?
CREATE VIEW Meeting_View AS SELECT Meeting.MEETING_NUMBER FROM Meeting m1 WHERE START_DATE < GETDATE() AND EXISTS (SELECT MAX(START_DATE) FROM Meeting m2 WHERE m1.MEETING_NUMBER = m2.MEETING_NUMBER) |
|
#3
|
|||
|
|||
|
Got it finished.I hope its right.Sorry I took so long:
CREATE VIEW Meeting_View AS SELECT Meeting.MEETING_NUMBER FROM Meeting m1 WHERE START_DATE < GETDATE() AND NOT EXISTS (SELECT MAX(START_DATE) FROM Meeting m2 WHERE m2.START_DATE > m1.START_DATE AND START_DATE < GETDATE()) |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Help!!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|