I need a quick look at my SQL query. It’s already given me a headache. Comparing some advice I have gotten, I could not figure out the proper format for my SQL. This is my code: Thanks in advance! EDIT: Currently I have this as the form: This is the insert query: Seems to submit the entry, but not the
Force index use in Oracle
I encountered this question in an interview and had no clue how to answer: There is a table which has a index on a column, and you query: The query takes too long, and you find out that the index is not being used. If you think the performance of the query will be better using the index, how could
Displaying the constraints in a table
Hello I am trying to display the constraints in one of my tables but for some reason I get the message no rows selected. Noted below is the table I have created. This is the code I am using to show my constraints. I am a rookie so I want to make sure I understand what is wrong. I have
Use a LIKE statement on SQL Server XML Datatype
If you have a varchar field you can easily do SELECT * FROM TABLE WHERE ColumnA LIKE ‘%Test%’ to see if that column contains a certain string. How do you do that for XML Type? I have the following …
Strategy for avoiding a common sql development error (misleading result on join bug)
Sometimes when i’m writing moderately complex SELECT statements with a few JOINs, wrong key columns are sometimes used in the JOIN statement that still return valid-looking results. Because the auto …
NHibernate to dynamically create/alter/delete tables
I know NHibernate is an ORM and it isn’t normally used to create tables but I also know that NHibernate is able to create an entire database given some mappings. I would like to know if there is an …
Check if Stored procedures have syntax errors
I have tons of stored procedures in my database. We are constantly changing the data structure (we are in development) Is there a tool that will tell me which stored procedures won’t compile? When …
sort the “rollup” in group by
I found that the “with rollup” option used with group by is very useful. But it does not behave with “order by” clause. Is there any way to order by the way I want as well as calculate the sub-totals? …
MAX on columns generated by SUM and GROUP BY
I’m trying to get the MAX on a column which is generated dynamically using the SUM statement. The SUM statement is used together with the ‘GROUP by’ syntax. This is the original query, however it needs to be modified to work with grouping, sums and of course MAX. As you can see SUM is adding all the values inside video_plays
Convert timestamp/date time from UTC to EST Oracle SQL
I have a field with a date/time value like this: It’s in UTC. In the query how can I convert this to EST? I’m trying something like this but it throws an error. Answer I had to tweak it slightly to get it to work on my database, but this worked: The key is the “at time zone” syntax.