query

MS Access Query "WHERE" Exception

I am writing an application in C# that reads info from a .mdb file using the System.Data.OleDb namespace. The table I am reading from contains information about a sample (number, index, date, etc). The number and date are required entries when a new item is added to the table, but the index is optional, so some samples do not have an ind...

bulk insert 3M records to SQLExpress

Hi, While trying to bulk insert 3M records from CSV file to SQLExpress database the procedure throw the timeout exception which was set to 30s. I tried to set the Connect Timeout to 1800 but again the procedure threw the same exception. Does anyone know whether the exception is thrown due to too many records or the timeout was not set ...

SQL Server Query monthly totals

I have a query that totals up all cases that were active on 01/01/2010. SELECT COUNT(CaseID) AS Total FROM dbo.ClientCase WHERE (CaseStartDate <= CONVERT(DATETIME, '2010-01-01 00:00:00', 102)) AND (CaseClosedDate >= CONVERT(DATETIME, '2010-01-01 00:00:00', 102)) OR (CaseClosedDate IS NULL) GROUP BY CaseStartDate I also...

How to query abstract-class-based objects in Django?

Let's say I have an abstract base class that looks like this: class StellarObject(BaseModel): title = models.CharField(max_length=255) description = models.TextField() slug = models.SlugField(blank=True, null=True) class Meta: abstract = True Now, let's say I have two actual database classes that inherit from StellarObjec...

Django query - "case when" with aggregation function

I have the following django model (mapped to table 'A'): class A(models.Model): name = models.CharField(max_length=64, null=False) value = models.IntegerField() ... I want to perform the following simple query on top: select avg(case when (value > 0 and value <= 50) then 0 when (value > 50 and value < 70...

html form to XML response and reply

I have a form that looks like this. Now a client has asked to convert this to a format that queries and sends response in XML. Can someone pint me to appropriate tutorial or example in PHP. There seems to be many ways of doing this <form action="" method='post'> <table> <tr><td>User Number </td><td><input type='text' name='task_user_no...

wordpress returning all the posts

Hi, I only want to return the latest 2 posts but my code returns all the posts, any idea how I can fix this? Code below, Thanks, R. <?php $postslist = query_posts('posts_per_page=2'); foreach ($postslist as $post) : setup_postdata($post); ?> <div class="post"> <?php the_date('d/m/y', '<div class="date">', '</div>'); ?>...

Subsonic query, i suck!

Hi all, I'm using subsonic 2.2 in one of my projects. I'm have a comment section where i query one table called Comments. First I query all records with ParentId=0, and then in the foreach statement I query all records with ParentId=currentRecord.Id. Now I know this is a bad habit but I don't know how to get around this in a single quer...

Passing a IS NOT NULL through a sqlparameter

I have a query in sql server 2008. That I want to either pass a value from the dropdownlist or IS NOT NULL (so it shows all of the values). What's the best way to handle this? I know you can't pass the string "IS NOT NULL" to the parameter. I'm a bit stuck on this one. ASP.NET 3.5 and SQL Server 2008. ...

using NOT IN for multiple tables

How can I simplify multiple 'not in' queries? Is it efficient to use multiple subqueries: Not in (...) and Not in (..) and Not in (..) I am using count (sorry forgot about that) Select count (VisitorID) from Company where VisitorID not in (select VisitorID from UserLog where ActionID = 2 ) and VisitorID not in (select VisitorID...

How to sort data depending on what day it was posted ?

Hello, How do you sort data which was stored in a mysql database depending on the days of the week in which the data was submited ?? I basically want to create a diary which outputs information in each day of the week depending on what day it was posted by dates so, Mon - Data in order of date Tue - Wed - e.t.c Any code examples and ...

MySQL How do I show month over month gains or losses?

MY question deals with month to month data changes..I want a simple (if possible) SQL query that will show the person , and month change grouped by person/month or similar.. the important part is to show gains and losses. For Example I have a table: (date simplified ) id | Date | Person | Sales ---|-----------|--------| ----- 1 ...

Summarize the result of the table

I am using PostgreSQL. I have the data in table like: Parent_id Count Read --------- ------ ------ 52405 2 False 52405 1 True Now i want to summarize the data like : Parent_id Count Read --------- ------ ------ 52405 3 False Count would be the sum o...

How to make an optimal hibernate query with three objets ?

I have a query but I dont know how to make it optimal. I have three objects. SCP Question : it has a field that points SCP (SCP_id) Answer : it has a field that points Question (question_id) How can I make a query that counts the number of answer within a given SCP ...

SQLite Query in Android Application

It is giving error at runtime : Application stopped unexpectedly - Am I going wrong anywhere ? Please help. Any help is appreciable. public Cursor getdata(String passTask) { //Cursor cursor = this.db.query(TABLE_NAME, new String[] { "totalHr" }, // "where task = ", passTask ,"", "", ""); //return cursor; String p_quer...

Removing null records from a set in Grails Controller

Hello again, so, Grails is making me feel quite stupid again, I'm new to this. I have A grails domain that maps a table thats in production on a postgresql database. I am trying to track progress on the project by a date field 'migratedDate'. Everytime a process takes place the field is timestamped. I can't seem to make a controller ...

Can same SQL query fetch different results ?

Hi, I have the following sql query which, for some strange reason, it doesn't display the same results. The back end is mysql database (innodb), the front end an Excel GUI. When run on Excel 2003, the following query shows all the correct records. However when run on Excel 2010, the results are different ! Same mysql database, just ...

My query filtering is not working the way I want it to

I have 3 ways I want to filter: by name by list and show all I'm using ASP.NET 3.5 and SQL Server 2008. Using ADO.NET and stored procs. I'm passing my list as a table valued parameter (but I'm testing with a table variable) and the name as a nvarchar. I have "show all" as ISNULL(@var, column) = column. Obviously the way I'm query...

search query "alien vs predator"

How do you do so that when you search for "alien vs predator" you also get results with the string "alienS vs predator" with the "S" example http://www.torrentz.com/search?q=alien+vs+predator how have they implemented this? is this advanced search engine stuff? ...

Teradata - Invalid Date supplied for FIELD

Hi all, I'm trying to query a table that has a varchar(100) "VALUE" column. This column can hold anything from a letter, a number or, in this case, a date. The date will always be entered in the table as 'YYYY-mm-dd'. However, when I run the following query: select * from myTable where VALUE = '2009-12-11' (Date, Format 'yyyy-mm-dd')...