Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

tsql - Conditional where statement in T-SQL -


i've got table returns history of value, current one, each date.

the oldest date main record. if value changed, new record created, old value, , main record updated new value. if happens again, third record created, contains old value.

so if value starts @ 4, changes 2, again changes 1. records go

1 4 2 

i'm creating inner join on table follows, gets max date of 3 above records, 2.. actual value need 4. easiest way tell if record historical 1 triageenddatetime null.

inner join (select emergencyattendanceid,min(sourcecreatedatetime) max_date                 factemergencyattendancetriagedetail                  group emergencyattendanceid) eaid                  on eaid.emergencyattendanceid = factemergencyattendancetriagedetail.emergencyattendanceid                 , eaid.max_date = factemergencyattendancetriagedetail.sourcecreatedatetime 

what need select second record, if exists. along lines of this.

 select emergencyattendanceid,min(sourcecreatedatetime) max_date     factemergencyattendancetriagedetail      if count(emergencyattendanceid) > 1 triageenddatetime null else not null     group emergencyattendanceid      inside inner join. 

can me this?

sample data

alt text

in above case, record 2 1 i'm after.

try this:

    select emergencyattendanceid       case when count(emergencyattendanceid) > 1           min           (           case when triagedatetime null sourcecreatedatetime end            )      else           min(sourcecreatedatetime)     end max_date       factemergencyattendancetriagedetail      group emergencyattendanceid  

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -