query

SQL query to calculate part of visit duration from log table

Hello, I have a table which logs the userid, course, sessionid and requestdate each time a webpage is loaded. I want to calcuate the duration per userid for a given courseid. It is problematic to do this due to overlapping timespans. The data provided here should result in 10 minutes duration per user for course 1. I can't seem to get ...

SQL Query : List the Most frequent Users of a Server

I am working on a one to many query for an assets database. Here is some sample data Server Name Application Primary_User Server1 SQL DBA Server1 Citrix IT Server1 Oracle DBA Server2 Sharepoint Web Server3 SQL ...

Query Oracle DB for timestamps when you know milliseconds

Hi, I'm currently getting the error: "java.sql.SQLException: ORA-01843: not a valid month" which I assume is to do with the way I am setting a timestamp... So I have a query like this : select * from A_TABLE where A_TIMESTAMP_COL < '1252944840000' But it doesn't work...and I don't want to have to convert it to a date ideally. Is the...

Should query languages have priority of operator OR higher than priority of AND ?

Traditionally most programming languages have priority of AND higher than priority of OR so that expression "a OR b AND c" is treated as "a OR (b AND c)". Following that idea search engines and query/addressing languages (css,xpath,sql,...) used the same prioritization. Wasn't it mistake ? When dealing with large enough data, that prior...

SQL query to get all values a enum can have

Postgresql got enum support some time ago. CREATE TYPE myenum AS ENUM ( 'value1', 'value2', ); How do I get all values specified in the enum with a query? ...

How to compare two column values which are comma separated values?

I have one table with specific columns, in that there is a column which contains comma separated values like test,exam,result,other. I will pass a string like result,sample,unknown,extras as a parameter to the stored procedure. and then I want to get the related records by checking each and every phrase in this string. For Example: T...

How to use a string literal to specify a column name in SubSonic 3.0

Here is a statement in SubSonic which does a find using the strongly typed column ProductId: var products = Product.Find(x => x.ProductID <= 10); Is there a way to not use a strongly typed column name and instead specify the column name with a string literal like so: var columnName = "SampleColumn"; var products = Product.Find(x => x...

ActiveRecord Query (Castle, Performance)

I've 3 tables: Parts: Name: internal name, Active: bool Languages: list of languages (English, French, German, ....) PartsTranslations: RealName and Id's of the other 2 tables. I would like to get a list of Parts telling me the internal name, active status and how many translations are missing (total lang subtract translations made)...

Query is slow while doing a NOT IN on a nested SELECT from another table

SELECT problems . * , users.id AS new_user_id, users.nick AS nick FROM problems, users WHERE problems.deleted =0 AND problems.topic_id =1 AND problems.user_id = users.id AND problems.id NOT IN ( SELECT DISTINCT (problem_id) FROM problems_attempted WHERE user_id =1 AND total_questions = ( attempted_right + attempted_wrong + skippe...

Simple Query using subsonic 2.2 with Oracle.dataclient error.

I am using subsonic 2.2 with Oracle provider. I can use active record but my simple query does not work! int record = new Select(VenApplication.ApplicationidColumn).From(VenApplication)().GetRecordCount(); The error that i got is ORA-00923: FROM keyword not found where expected Description: An unhandled exception occurred during the ...

how to use alias field in query ? (oracle 10g)

hi i writ thie query: select Fname,Age*2 as Demo from Men where Demo = 5 i get error - ORA-00904 (Demo not identified ) how i can use it ? thank's in advance ...

sql counting rows

I have the following table in MySQL... CREATE TABLE `visits` ( `id` int(10) unsigned NOT NULL auto_increment, `visit` datetime NOT NULL default '0000-00-00 00:00:00', `bulletin` int(11) NOT NULL default '0', PRIMARY KEY (`id`) ) Where "visit" is the time a visit occurs, and "bulletin" is the article requested at that time. I...

How to check the Resultset status?

This is for vbscript application. Dim objRs set objRs = server.CreateObject("ADODB.Recordset") set objRs = objConn.Execute(sql) When the sql statement got syntax error, it will cause the whole ASP page into error. I want to do logging by performing the following: When the query go into error, log the sql into a text file ...

How to write a search query for this form

I want to write a search query that search on the criteria like city, rent, area. i am new to database and sql queries. How to write query. Please help. Any suggestions will be highly appreciated. My form snapshot is here ->> ...

mysql format results as columns not rows...

Hi, Using MySQL Server, I have a table structure like: (Table test) id Name 1 "test1" 2 "test2" 3 "test3" When I perform the following query: "Select name from test", the results are: "test1" "test2" "test3" How can I adjust this query so the results are columns, as such: "test1" "test2" "test3" ...

In django, how to write a query that selects all possible combinations of four integers?

I'm writing a Game Website, where the draw is a series of four digits. e.g 1234 I"m trying to write a query in django that will select all winners based on the four digits entered. winners are any combination of the same numbers or the same combination, 1 2 3 4, 2 3 1 4, 4 1 3 2 are all winners. how is the most efficient way to write ...

MySQL - Query to move part of 1 field's contents to a new field

I have a table called cartypes which currently has 2 fields: id & type. I am adding subtype and I want to move the contents after the dash - from the field called type and put those contents into subtype. Disposing of the dash (any extra whitespace too for that matter). What's the best SQL query for this? before: id type ...

Searching multiple tables with Subquery

Hello, What I need to do is searching from companies and tags table and listing companies. My table structure is as follows; tags (tag_ID, tag) tag_relation (tag_ID, company_ID) companies (company_ID, company_name, company_description) The query should be able to search both company info (name, description) and tags. If tag searched,...

Lock a table in SQL Server

Is there a command/SQL query to lock a particular table in MS SQL Server to stop all related transactions using ODBC? ...

SQL query ...multiple max value selection. Help needed

Business World 1256987 monthly 10 2009-10-28 Business World 1256987 monthly 10 2009-09-23 Business World 1256987 monthly 10 2009-08-18 Linux 4 U 456734 monthly 25 2009-12-24 Linux 4 U 456734 monthly 25 2009-11-11 Linux 4 U 456734 monthly 25 2009-10-28 I get this result with the query: ...