March 8, 2012 at 6:27 pm
Hi,
I have student table with these values and columns
DECLARE @student TABLE(St_Name VARCHAR(100), St_Code INT, St_Date DATETIME)
INSERT INTO @student
SELECT 'Arvind',35,'2/3/2012' UNION ALL
SELECT 'Arvind',78,'2/24/2012' UNION ALL
SELECT 'Arvind',78,'2/10/2012' UNION ALL
SELECT 'Ram',35,'2/20/2012' UNION ALL
SELECT 'Krishna',35,'4/1/2012' UNION ALL
SELECT 'Ravi',78,'2/20/2012' UNION ALL
SELECT 'Ravi',78,'2/14/2012'
First I need to check whether the Student Has the st_code=78, if it is not there then need to get the top most student code that contains st_code=35.
Then getting the top most st_code=35 record, so we need to add 14 days to that st_date. Adding after 14 days we need to display and that must be less than the getdate().
Next->
If the St_code contains both 78 and 35 , then i need to get the top most student code that contains st_code=78.
Then getting the top most st_code=78 record, so we need to add 14 days to that st_date. Adding after 14 days we need to display and that must be less than the getdate().
So, Here how can i check both two conditions to write the query.
Help me Please..
Thanks,
March 8, 2012 at 6:41 pm
Please take the time to read the first article I reference below in my signature block. It will step you through the things you need to do to post the information we need to really help you. Also, be sure to post the expected results based on the sample data you will provide.
I could probably work through your problem description and figure out what you are trying to accomplish, but if you show us, you will get much better answers faster, plus tested code.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply