I have legacy sql query that selects bit masks (among other data), something like: How do I group this output like: That should be 3 Answer In order to do bit-wise logic you have to do a “bit” of math. (Bad puns are free around here :-). Oracle defines the BITAND function. To get a bitwise ‘…
Tag: sql
How to update ms access database table using update and sum() function?
I have Two tables in my access database table1(ID,productname,qunatity,remainder) table2(ID,productname,sales) these tables are related together using “product name” ,How can I update”reminder” from table1 with the value of “quantity form first table – Sum(sales) from secon…
WITH(NOLOCK) : where & when to use
I have 15 tables which are normalized to contain records and many user may be inserting/updating data in these tables( No two user can update the same record(s) simultaneously, this is restricted by client implementation). these 15 tables are updated 1 by 1 in a stored procedure. WITH(NOLOCK) is used where se…
Need to combine two columns in a table [closed]
I need to combine two column in a table using alias name select firstname as fn, lastname as ln, userid, fn + ” + ln as fullname from users Error is Invalid column name …
EF6 Stored Procedure does not accept parameters
I am using EF6 and I need to execute stored procedure. It takes two parameters: mIIN varchar(12), which is input string mXMLOutput varchar(max), which is the result of execution It works fine when I call it from Management Studio. However, when I use the following code: which results in the error Procedure or…
SQL select where column begins with Letters
I have a table tbl1 with row of data: I want to query the the Legal_Doc_No of each ID. The value of each ID is either the TIN or the SSS column. How can I query the TIN and SSS column starting with letters (none) so that only values starting with numbers will be assigned to Legal_Doc_No Answer Most databases
How to do a where exists in nested query with SQLAlchemy?
I’m trying to do a WHERE EXISTS clause in SQLAlchemy. The SQL looks like this: Is it possible to do this in SQLAlchemy without using raw SQL? I’ve tried this but it doesn’t seem to be returning the correct results: Answer Use sqlalchemy.orm.aliased() and exists():
Cannot catch SQL Server alter table error
It is a really simple code, but it cannot catch the error. Or how to catch the error? Thanks. Answer Errors that occur as a result of batch recompilation after deferred name resolution cannot be caught at the same level the error occurs. One work-around is to wrap the DDL in dynamic SQL:
Summing edges properties for order by in select statement
I’m trying to do a select statement to order the result set by force of connections between them. ‘isConnectedTo’ edges relate Entities to another Entities The tricky part is I have double connections between the same entities as so: So Mike is connected to John which is connected to him too…
Teradata SQL Same Day Prior Year in same Week
Need help figuring out how to determine if the date is the same ‘day’ as today in teradata. IE, today 12/1/15 Tuesday, same day last year was actually 12/2/2014 Tuesday. I tried using current_date – INTERVAL’1’Year but it returns 12/1/2014. Answer You can do this with a bit of ma…