Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Need Help In Query . Expand / Collapse
Author
Message
Posted Tuesday, September 11, 2012 11:52 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, May 11, 2015 8:00 PM
Points: 249, Visits: 601
Could you please help me find records described as per below scenario.



Campus
code,address,CampusID(PK)
Data:-
DEL,ABC,1
CHN,DDJ,2
MUM,PQR,3
BNG,WRT,4
PUN,BNM,5

Enroll
StudId,CampusID,EnrollDate,LstAttendDate,Enrolid(PK)
1,2,15-06-2012,NULL,1001
1,5,31-05-2011,31-05-201,1002


ChangeStatus
StudId,Enrolid,NewStatId,PrevStatId,ChangeID(PK)
1,1001,1,0,5001
1,1001,2,1,5002
1,1001,3,2,5003

StatusMast
StatId Description
1,Active
2,Present
3,External etc.

In the above table resticted StatId are below.7,9,11,13 and 15.and rest are Active status.



Studunt can change campus or course any time.(course refers Enrolid).

Now i want to fetch studunt's old campus and new campus (Refer Campus Table) on below conditions.

1) students who went Active at Transferred From Campus before or after any of the restricted Statuses listed above in StatusMast table(i.e.StatId are - 7,9,11,13 and 15)
2)students who had an Active status at any time before or after any of the restricted Statuses at the Transferred To Campus
3)Students who’s Previous Status was Active and the corresponding New Status is in the restricted Status list at either the Transferred From Campus or the Transferred To Campus


Thanks
Abhas.
Post #1357795
Posted Wednesday, September 12, 2012 3:15 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, April 22, 2015 4:35 AM
Points: 2,920, Visits: 5,354
Looks like homework to me...
What have you tried so far?


_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1357852
Posted Wednesday, September 12, 2012 10:55 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, May 11, 2015 8:00 PM
Points: 249, Visits: 601
Thanks CELKO.

I will try this one.

Thanks
Abhas
Post #1358337
Posted Monday, September 17, 2012 2:31 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, May 11, 2015 8:00 PM
Points: 249, Visits: 601
Still not tried anything as busy on other task.
If u have any idea in the mind then pls share.
Post #1360025
Posted Monday, September 17, 2012 2:47 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:56 AM
Points: 7,151, Visits: 14,996
abhas (9/17/2012)
Still not tried anything as busy on other task.
If u have any idea in the mind then pls share.


It's a simple assignment. What have you tried so far?


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1360030
Posted Tuesday, September 18, 2012 12:16 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, May 11, 2015 8:00 PM
Points: 249, Visits: 601
Hi Chris,
I tried using CTE but not able to do.
Post #1360575
Posted Tuesday, September 18, 2012 12:51 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Monday, May 11, 2015 9:01 PM
Points: 612, Visits: 990
abhas (9/18/2012)
Hi Chris,
I tried using CTE but not able to do.


Please post your query.


--rhythmk
------------------------------------------------------------------
To post your question use below link

http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1360582
Posted Tuesday, September 18, 2012 2:13 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:56 AM
Points: 7,151, Visits: 14,996
abhas (9/18/2012)
Hi Chris,
I tried using CTE but not able to do.


No problem - post what you have, we'll help you make it work.


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1360612
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse