SQl CASE Statement

Something like.. ORDER BY CASE WHEN ISDATE(DateTime) = 1 THEN CASE DateTime WHEN <= ‘2016-03-01’ THEN 1 — Preseason WHEN >= ‘2016-03-31’ THEN 3 — PostSeason ELSE 2 END — Season ELSE 4 END, — Not a date, figure out how to handle DateTime

Convert this sql command to c# linq

var query = ( from v in dbContext.UnitFeatureValue join u in dbContext.Unit on v.FK_Unit_ID equals u.ID join t in dbContext.FeatureTitle on v.FK_FeatureTitle_ID equals t.ID where v.FK_Unit_ID == 15 && t.canMoreSelect == 1 select new { v.FK_Unit_ID, u.unitNumber, u.unitTitle, t.featureTitleName, }).Distinct();

How to create a specific SQL Server stored procedure? [closed]

Yet another option. Not sure if I agree with the last record of the desired results. I have 2019-01-07 while you have 2019-01-08 Example or dbFiddle Select A.[Name] ,[Begin_Date] = convert(datetime,left(dateadd(DAY,N ,[Begin_date]),10)+’ ‘+BegTime) ,[End_Date] = convert(datetime,left(dateadd(DAY,N+NxtDay,[Begin_date]),10)+’ ‘+EndTime) From YourTable A Cross Apply ( values ( left(replicate(Schedule,10),datediff(DAY,Begin_Date,End_Date)) ) )B(S) Cross Apply ( Select N=N-1 ,Subs=substring(B.S,N,1) From … Read more

SQL where clause odd behavior [closed]

The problem with your original query is you are asking to return results where the PermissionId is equal to two values at the same time – meaning the same row – this is impossible. However you can get return the UserID that has both PermissionId =5 AND PermissionId =7 by using a GROUP BY with … Read more

Is it possible to write single query on two table which are not connected to each other?

A Cartesian join (note there is no JOIN condition). All possible combinations of records are in the results: tableA (charfield Char(2)) tableB (numberfield Number(1)) INSERT ‘A’ INTO tableA; INSERT ‘B’ INTO tableA; INSERT 1 INTO tableB; INSERT 2 INTO tableB; SELECT * FROM tablea CROSS JOIN tableb Results: charfield|numberfield ===================== A |1 A |2 B … Read more