Skip to content

Tag: tsql

Getting the primacy function for an emolyee

I have this following query to get the primacy for an employee : My output is like below : What I want is to get primacy (primary,secondary, tertiary) to each function like below : The function having the minimal sumOrder will be the primary function and so on. Answer You can use a ROW_NUMBER() ordered by the…

Update column with below query?

How do I write this query to update a column based on the case statement? Answer As commented, you query looks pretty good, apart from these: the ORDER BY clause does not make sense; an UPDATE query does not return any record, so ordering is out of scope for the same reason, you don’t have to alias the …

Query works on SQLite but fails on SQL Server

The following query works for me in SQLite. But in SQL Server, it gives me an error. Invalid column name ‘VehId’. And the editor puts a red squiggly line under the last VehId (but not the first). As you might expect, Vehicles.Id is the primary key. I’m trying to find all foreign keys in Tran…

Regular expression blacklist

Can someone explain to me the meaning of the following query: SELECT message.message FROM message CROSS JOIN Blacklist WHERE(message.message LIKE {fn CONCAT({fn CONCAT(‘%’, Blacklist.Words)}, ‘%…