Good Day, I am using the following code to calculate the 9 Day Moving average. But it does not work because it first calculates all of the returned fields before the limit is called. In other words it will calculate all the closes before or equal to that date, and not just the last 9. So I need to calculate
Tag: sql
ORA – 00933 confusion with inner join and “as”
I have this query of getting data from two tables using an inner join, but I get the error SQL command not properly ended with an asterix under “as”: select P.carrier_id, O.order_id, O.aircraft_id, O….
SQL Server Profiler deprecation – Replacement?
I am developing ASP.NET and SQL Server applications, sometimes i am having trouble with a SQL Query, and i would like to see the SQL Servers “response” and not just the ASP.NET error message (Which is not always very helpfull) The Profiler.exe tool in SQL Server is capable of this, but im reading …
Oracle SQL. How to execute query one by one
Could you help me, how can I execute query one by one in Oracle SQL Developer? When there’s one query system works correctly. But when I write 2 or more and press “ctrl” + “enter”, System marks out all queries and trying to execute all of them. Answer Separate each query by semi-…
SQL SERVER: Check if variable is null and then assign statement for Where Clause
I am trying to achieve something like the below in WHERE clause in sql. I tried the following: which is wrong. Can anyone help in framing the exact statement. Thanks! Answer Isnull() syntax is built in for this kind of thing. For your example keep in mind you can change scope to be yet another where predicate…
Null or empty check for a string variable
I want to know whether the above piece of code works in checking if the variable is null or empty. Answer Yes, that code does exactly that. You can also use: Edit: With the added information that @value is an int value, you need instead: An int value can never contain the value ”.
Based on date range how to get unique, new, and repeat results?
I have a database table with datetime field and also contains user id (foreign key). I need to get the activity of unique, new, and repeat users. If a user does some activity, a database row is …
SQLite, insert variable in my table (c# console app)
I was wondering if it is possible to insert a variable in my SQLite table (like the TheName in the example code) , and if it is how are you able to do it ? Answer You need parameterized queries:
Optimize BETWEEN date statement
I need help optimizing a Postgres query which uses the BETWEEN clause with a timestamp field. I have 2 tables: containing about 3394 rows containing about 4000000 rows There are btree indexes on both PKs id_one and id_two, on the FK id_one and cut_time. I want to perform a query like: This query retrieves abo…
Using SQL Merge or UPDATE / INSERT
I have a table (Customer_Master_File) that needs to updated from flat files dumped into a folder. I have an SSIS package that runs to pick up the flat files and imports them into a temp table (temp_Customer_Master_File) What I have been unable to do is this: for each record in the temp table, if the Customer_…