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 |
|
anilr499
Starting Member
18 Posts |
Posted - 2012-06-25 : 03:23:26
|
| Hi,i have two tables namedPRJCOMMENT and PRJSCHEDULE ...Now i need to get the latest date fromtable name---- column namePRJCOMMENT---- date_uploadPRJSCHEDULE ---- prc_date_updatedbased on prj_id...in the above two tables they have different prj_id'si mean they dont have common prj_id...now i need to get the latest date from them depending onprj_id....how can i relate both in one query an get the latest date...i need to check for prj_id in both tables...how can i proceeedd...than you... |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-25 : 04:30:00
|
| Not clear what yoou want but maybe select prj_id, max(date_upload), max(prc_date_updated)from(select prj_id, date_upload, prc_date_updated = converrt(datetime,null)from PRJCOMMENTunion allselect prj_id, null, prc_date_updatedfrom PRJSCHEDULE) agroup by prj_id==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
sakthiananth
Starting Member
2 Posts |
Posted - 2012-06-25 : 05:47:38
|
| Thank you dude.. it's useful to me and also i've one doubt that why we're using "NULL" here Let's keep learning to explore towards future.): |
 |
|
|
anilr499
Starting Member
18 Posts |
Posted - 2012-06-25 : 06:22:26
|
| hi nigelrivett,thank you for your support ...i used your query as shown below select prj_id, max(date_upload) , max(prc_date_updated) from(select prj_id, date_upload, prc_date_updated = convert(datetime,null)from PRJCOMMENTunion allselect prj_id, null, prc_date_updatedfrom PRJSCHEDULE) a WHERE prj_id='PRJ0000704' group by prj_idmy output isPRJ0000704 28/02/2012 NULLi need first two columnsi mean we need to check in two tables ...but should display date in only one column...because we dont get two dates at a time...for example..if PRJCOMMENT contains the required datethen PRJSCHEDULE does not contains any thing and vice versa...because i need to display the output date in a single column in my report..... thank you.... |
 |
|
|
|
|
|
|
|