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 |
|
shm
Yak Posting Veteran
86 Posts |
Posted - 2008-09-29 : 04:27:46
|
| in the query am getting all the date but i want the date which is first entered..for ex:2008-04-02 00:00:00.0002008-04-02 12:43:50.0002008-04-02 00:00:00.0002008-04-02 00:00:00.000in this i want the date 2008-04-02 12:43:50.00. |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2008-09-29 : 04:29:48
|
| what logic dictates that 12:43:50.000 comes before 00:00:00.000 of the same day? what do you mean by 'first entered'?Em |
 |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2008-09-29 : 04:30:33
|
| select min(mydate) from table.or select max(mydate) from table depending on how you interepret your question. |
 |
|
|
shm
Yak Posting Veteran
86 Posts |
Posted - 2008-09-29 : 05:16:58
|
| means in the same day some may the change and save the data...in that day first at wt time is changed and saved..for that i want to know...for more clarification am sending part of thequery.. SELECT CRA.CAH_ASSIGNED_DATE as ASSIGN_DATE ,CR.DELIVERY_DATE as DELIVERY_DATEFROM CHANGE_REQ_ASSIGN_HISTORY CRAINNER JOIN CHANGE_REQ CR ON CR.CRQ_SEQ_NO = CRA.CRQ_SEQ_NOINNER JOIN PROJECT_MODULE PM ON PM.PMO_MOD_SEQ_NO = CR.PMO_MOD_SEQ_NO as shown in the above query...other than this there is no other conditionthe below is the result am getting assign_date delivery_date 2008-07-04 19:39:09.453 2008-07-15 00:00:00.0002008-07-07 10:19:47.017 2008-07-15 00:00:00.0002008-07-07 10:21:08.293 2008-07-15 00:00:00.0002008-07-07 10:45:09.640 2008-07-15 00:00:00.0002008-07-15 11:24:35.420 2008-07-15 00:00:00.0002008-07-15 11:28:22.727 2008-07-15 00:00:00.000but if i give the min()then the result wil only come 2008-07-04 i want all the date that is 2008-07-07 10:21:08.293 and 2008-07-15 11:24:35.420 for the delivery_date 2008-07-15 00:00:00.000 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-29 : 06:01:05
|
[code]SELECT ASSIGN_DATE, DELIVERY_DATEFROM ( SELECT CRA.CAH_ASSIGNED_DATE as ASSIGN_DATE, CR.DELIVERY_DATE as DELIVERY_DATE, ROW_NUMBER() OVER (PARTITION BY DATEDIFF(DAY, 0, CRA.CAH_ASSIGNED_DATE) ORDER BY CRA.CAH_ASSIGNED_DATE) AS RecID FROM CHANGE_REQ_ASSIGN_HISTORY as CRA INNER JOIN CHANGE_REQ as CR ON CR.CRQ_SEQ_NO = CRA.CRQ_SEQ_NO INNER JOIN PROJECT_MODULE as PM ON PM.PMO_MOD_SEQ_NO = CR.PMO_MOD_SEQ_NO ) AS dWHERE RecID = 1[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-29 : 06:25:28
|
quote: Originally posted by shm means in the same day some may the change and save the data...in that day first at wt time is changed and saved..for that i want to know...for more clarification am sending part of thequery.. SELECT CRA.CAH_ASSIGNED_DATE as ASSIGN_DATE ,CR.DELIVERY_DATE as DELIVERY_DATEFROM CHANGE_REQ_ASSIGN_HISTORY CRAINNER JOIN CHANGE_REQ CR ON CR.CRQ_SEQ_NO = CRA.CRQ_SEQ_NOINNER JOIN PROJECT_MODULE PM ON PM.PMO_MOD_SEQ_NO = CR.PMO_MOD_SEQ_NO as shown in the above query...other than this there is no other conditionthe below is the result am getting assign_date delivery_date 2008-07-04 19:39:09.453 2008-07-15 00:00:00.0002008-07-07 10:19:47.017 2008-07-15 00:00:00.0002008-07-07 10:21:08.293 2008-07-15 00:00:00.0002008-07-07 10:45:09.640 2008-07-15 00:00:00.0002008-07-15 11:24:35.420 2008-07-15 00:00:00.0002008-07-15 11:28:22.727 2008-07-15 00:00:00.000but if i give the min()then the result wil only come 2008-07-04 i want all the date that is 2008-07-07 10:21:08.293 and 2008-07-15 11:24:35.420 for the delivery_date 2008-07-15 00:00:00.000
cant understand how you will get 2008-07-07 10:21:08.293 as min value when you have 2008-07-07 10:19:47.017? |
 |
|
|
shm
Yak Posting Veteran
86 Posts |
Posted - 2008-09-29 : 09:51:59
|
| the above solution is working fine..thank u so much for all... |
 |
|
|
|
|
|