I have a table names ‘tbl_featured_professional’ where fields are: id, user_id, ranking and score, createdDate What I want is first 40 records are ordered from ranking (which is unique) and all …
How to create a constraint for conditional unique values?
I am using SQL Server. I have this table: CREATE TABLE Student ( ID int PRIMARY KEY, FirstName varchar(100), LastName varchar(100), Active bit; ) I want to have unique(FirstName, …
If else using case for returning value
I am trying to do an if else statement using CASE. If no records, then make it 0 then +1. Or else, just take the last record then +1. At first try i used ISNULL(statement,0). But it doesn’t have else …
How to select rows from table where group does not contain value
I have a table that contains the following fields: Thedate,Thetime,Course,OR,L1R,L2R,L3R I would like to only return values if a group (Thetime) does not contain the value “0” in L3Ra column. I …
Multiple CTE where clauses referece CTW column
For example WITH UserDetail (UserId, UserName) AS ( SELECT TOP(10) U.UserId,U.UserName FROM UserTable U ), UserAction (ActionName,ActionType) AS ( SELECT TOP(10) A.ActionName,A….
Understanding where clause vs join
Can somebody explain the difference between below query examples. select column1,column2 from table1 join table2 on table1.columna = table2.columna and columna=’1234′ vs select column1,…
`?` placeholder for SQL `IN` condition with persistent’s `rawSql`
I would be happy to use ? placeholder to populate ids for SQL IN clause. Unfortunately the following does not work Such code results in database error similar to: Wrapping ? placeholder with brackets (e.g. IN (?)) gives another type of error: Is there a way to accomplish this? P.S. Looks like it’s a hor…
Sql agent job last run status
I have N jobs with M steps in each, that could change any time(Add/delete some steps). Jobs have different schedule to run. I want a query to get last run status, job id, job name of each job. Is it …
Can Anyone an Hint with the following SQL
imagine i have a table like this Bikename Username NumOfUsages LastTimeOfUsage Bike1 Haldi 5 2018-12-13 12:00:00 Bike1 Torte 1 2018-08-15 12:00:00 Bike2 Haldi …
How to do SQL Join with many tables (FK tables have looped results sharing ID)
I am newish to SQL and Join statements and I am way out of my league at the moment I currently have 6 Database Tables that are all linked to the main 7th table based on the main tables ID, however all …