am having a table which contains no,name,dob,alivestatus(yes/no) that whether he s alive or not ,weddingdate, couplename,
i want to display the wedding report. if the name of the member and cname is alive means i want to display their name with wedding date. how to write a query for this pls help me sir. here s my sample table
| No | Name | Dob | alive status | weddingdate | couplename |
| 1 | sanju | 2/2/1980 | yes | 6/23/2009 | Divya |
| 1 | divya | 3/4/1983 | yes | ||
| 2 | ashok | 4/4/1983 | yes | 3/3/2010 | anju |
| 2 | anju | 3/6/1986 | no | ||
in this basic details of sanju and other members details are inserted. sanju's wife is divya. so divya doesnt contain the weddingdate and couplename bcse already enterd in sanju's details. so i want to check the husband and wife s alive or not if they both alive means i want to display the wedding report
Posted Sep 30, 2013, 4:41 AM
Hope this helps you.
raji bPosted Oct 3, 2013, 8:19 AM
thanks sir. i correct my mistake instead of putting where i put and now it corrected and runned sussefuly thanku so muchhh
Posted Oct 3, 2013, 12:55 AM
raji bPosted Oct 2, 2013, 10:41 AM
i want to display the wedding date between 2 specified dates. for eg:
from date:6/22/2013 todate: 6/28/2009 means,
this is my query,
select Rtrim(w1.Member_Name)+'&'+ w1.cname as name ,CAST(DAY(w1.wdate) AS VARCHAR(2)) + ' ' + DATENAME(MM, w1.wdate) AS wdate from Family_Member w1 inner join Family_Member w2 on w1.M_No= w2.M_No and w2.alivestatus =w1.alivestatus and w2.alivestatus ='yes' and w1.cname = w2.Member_Name and DATEADD(YEAR, DATEDIFF(YEAR, w1.wdate, '9/27/2009'), w1.wdate) BETWEEN '9/27/2009' AND '9/30/2009' OR DATEADD(YEAR, DATEDIFF(YEAR, w1.wdate, '9/30/2009'),w1.wdate) BETWEEN '9/27/2009' AND '9/30/2009' ORDER BY CASE WHEN DATEADD(YEAR, DATEDIFF(YEAR, w1.wdate, '9/27/2009'), w1.wdate) BETWEEN '9/27/2009' AND '9/30/2009' THEN 1 ELSE 2 END, DATEPART(MONTH, w1.wdate), DATEPART(DAY, w1.wdate)
its gets error. the error s n bold text. this bold text displays the full name. It is not checked the alive status
raji bPosted Oct 2, 2013, 10:41 AM
i want to display the wedding date between 2 specified dates. for eg:
from date:6/22/2013 todate: 6/28/2009 means,
raji bPosted Oct 1, 2013, 11:22 AM
Posted Oct 1, 2013, 10:42 AM
Can you please explain bit more?
Thanks
Murali
raji bPosted Oct 1, 2013, 9:36 AM
i want to display the name, wedding date as specfied from date to date for eg
wedding date fromdate 6/20/2008 todate 6/25/2009 means
sanju 6/23/2009 is displayed
my query is
so pls correct my query
raji bPosted Oct 1, 2013, 6:50 AM
raji bPosted Sep 30, 2013, 4:27 AM
Posted Sep 30, 2013, 2:59 AM
Posted Sep 30, 2013, 2:50 AM
you need to use self-join.
select
w1.Name,w1.CoupleName,W1.WeddingDate
from wedding w1 inner join Wedding w2 on
w1.CoupleName = w2.CoupleName and w2.[Alive status]= 'yes'
and w2.coupleName <> '' and w1.WeddingDate <> ''
Please let me know, if it is not solving your problem.