Can somebody help me figure out how to write the following SQL using Rails (I’m using Rails 4) Activerecord methods? I know you can do this with find_by_sql but I’d like to preserve the active record relation. Here’s the sql for a postGreSQL db that I’m trying to create: For my subquer…
Tag: sql
Does Order of Fields of Multi-Column Index in MySQL Matter
I know the importance of indexes and how order of joins can change performance. I’ve done a bunch of reading related to multi-column indexes and haven’t found the answer to my question. I’m curious if I do a multi-column index, if the order that they are specified matters at all. My guess is…
Calling Stored Procedure while passing parameters from Access Module in VBA
I am working in Access 2010 with a Microsoft SQL Server 2008 backend. I have a stored procedure that inserts new values(supplied by the parameters) into a table. The values assigned to the parameters are obtained from files stored in a folder. The Windows File System is used to scan a particular folder to mak…
Dynamics AX strange index functionality
At work we have a customer which doesn’t allow synchronizing. They have a database trigger which stops all Dynamics’ synchronization stuff. Now we are moving on to a plan where the synchronisation is allowed but I have to make a list of all indexes that do not match between AX and the SQL database…
mysql compare specific date
I have a table which contains a varchar field containing date like ’15 May 2015 – 03:10 am’ I have to compare all date in this table with the current date to retrieve row which are next the current …
How to SUM() for past 3 months for every field in a column
I have a table in MS Access that looks something like this And I want to count for every item in every month, what’s the sum of the past 3/6/12 months and it should look something like this Is there anyway this can be done in SQL queries? Answer Try a self-join on Item and t2.Date <= t1.Date and t2.D…
SQL Server: how to select records with specific date from datetime column
I am pretty new to SQL and hope someone here can help me with this: I have a table with one column dateX formatted as datetime and containing standard dates. How can I select all records from this table where this dateX equals a certain date, e.g. May 9, 2014 ? I tried the following but this returns nothing e…
oracle 12c – select string after last occurrence of a character
I have below string: So I want to select Sentence since it is the string after the last period. How can I do this? Answer You can probably do this with complicated regular expressions. I like the following method: Nothing like testing to see that this doesn’t work when the string is at the end. Somethin…
Checking for empty or null JToken in a JObject
I have the following… JArray clients = (JArray)clientsParsed[“objects”]; foreach (JObject item in clients.Children()) { // etc.. SQL params stuff… command.Parameters[“@MyParameter”]….
Execute query using C# [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 8 years ago. Improve this question I am trying to execute some SQL code, connected directly to my database, but I don’t k…