query

constructing a query for the following table

can anyone generate a query for me. Lets say i have a table sales(saleID, date_of_sales, customerID, itemID, saleprice) date_of_sales is the datetime field which stores the time of the sale. customerID is self exlpaining tells to whom item was sold. itemID is ID of the item sold. saleprice is the price that the item was sold. I ...

Optimising page processing by creating advanced SQL query

Hi there. I have this weird code on site. It gets all records (order by pozycja), then it creates some kind of stack and limits shown records to 10. However if there are over 200 records, it takes too long, because it's processing whole table, instead of 10. Values used: $int_ilosc_na_strone = 10; $liczba_wierszy = 200; Podzial_na_pod...

linq query lock issue (linq to sql)

I got a linq query time out exception. After a bit search online, using TransactionScope to make it 'nolock' gets my vote. However, after using the below code, i still get the same time out exception. Any help is appraicated, thanks in advance. IEnumerable<IGrouping<string, Log>> grps = logs.GroupBy(l => l.msg_shortdesc); using (var t =...

Complex querying with NHibernate

Hi, I have this problem: When I try to implement Ayende's complex searching found at: http://ayende.com/Blog/archive/2006/12/07/ComplexSearchingQueryingWithNHibernate.aspx with the object graph: Person: M:1 Address: M:1 Street: M:1 Place: ...

oracle query execution time

Hi! I would like to get my guery execution time from Oracle DB. I dont want the time when Oracle finish to print results. In MySQL it is easy to get execution time from shell, but in SQL Plus there are no such thinks. Thanks for any help! ...

mysql_num_rows for an mysql object?

Hi. How do I find mysql_num_rows for an object. This gives an error: $query = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_object($query); echo mysql_num_rows( $row ); Warning: mysql_num_rows() expects parameter 1 to be resource, object given ...

Changing params for search with rails and sunspot

This seems like a common task, I'm sure others have come across it. If my controller says this : def index s = Sunspot.search Organization do |query| query.keywords params[:q] unless params[:q].blank? query.with(:searchable).equal_to(params[:filter_by] == 'published' ? 'true' : false) if params[:filter_by] .. How do I: ....

How to use like operator in SQL?

I want to select from C_Table where Name='John' and use like operator for example select Name from C_Table where Name='John' AND where Details like %Boy% How to do this? Please help me... (Table name is C_Table) ----------------------------------------------- Name | P_No | C_No | Details | ---------------------------...

Why in the first case displays debit = 'null', and the second the right amount

Why in the first case displays debit = 'null', and the second the right amount ~ SELECT o.kadastr, /* Кадастровый номер */ d.ar_inn, /* ИНН арендатора */ o.adres, /* Адрес участка */ r.name, /* ФИО арендатора */ o.pl_common, /* Общая плащад...

Query to elimate multiple rows with multiple dates

I have a table:- SKU DATE VALUE ABC 2 Aug 10 100 ABC 15 Aug 10 150 ABC 20 Aug 10 180 DEF 2 Aug 10 130 GHI 3 Aug 10 120 JKL 2 Aug 10 140 JKL 20 Aug 10 160 I want it to be:- SKU DATE VALUE ABC 20 Aug 10 180 DEF 2 Aug 10 130 GHI 3 Aug 10 ...

sql server 2000 instance specific setting to cause varchar to int error

Hi I am having an inconsistent issue being produced on one of my servers whereby I have the following Select * from SomeVarcharTable v join SomeIntTable i on i.MyInt=v.MyVarchar Where v.Id = SomeID The "MyVarChar" column is surprisingly of type varchar, and "MyInt" is of type int. Whats curious is that when I run this on my develop...

Google App Engine : Cursor Versus Offset

Do you know which is the best approach for fetching chunks of result from a query? 1.Cursor q = Person.all() last_cursor = memcache.get('person_cursor') if last_cursor: q.with_cursor(last_cursor) people = q.fetch(100) cursor = q.cursor() memcache.set('person_cursor', cursor) 2.Offset q = Person.all() offset = memcache.get('offse...

Initialize to some data, if data is not present in certain fields

I want to put some same value in some fields where data is not present, for that do I need to query each field and see if there is data present or not and accordingly put the data, or there is some other work arround. Like Name Age City N 22 J K K 23 L Here I want to put data on those fi...

SQL - fetch latest row with data in specific column or just latest row if no data in that column

I have a table that records a history of address updates, called transaction. The schema is something like row_id (int, PK), user_id (int), address1 (varchar), transdate (timestamp). I want to query the table and have a single row returned for a user showing what is the latest row (i.e. greatest timestamp), but if there is data in the ...

MS Query to exclude state abbreviations

I have a query that I would like to exlude US States from. I am trying to find all data related to countries other than the US. I have the abbreviations for all the US States and can either link the table to the query and exlude them somehow or write a statement in the query to exlude them. But, I don't know how to do either. I thought I...

HIbernate Entity Manager: How to cache queries?

I am using the Hibernate 3.5.1 and EntityManager for data persistence (with JPA 2.0 and EHCache 1.5). I can obtain the query by the following code: EntityManager em; ... Query query = em.createQuery(...); ... Now, the problem is that EntityManager's createQuery() method returns javax.persistence.Query which, unlike org.hibernate.Query...

MERGE Command in SQL Server

Hi folks, I have been using the statement insert into target select * from source where [set of conditions] for a while. Recently found this MERGE command that will be more effective to use for my purpose so that I can change the above statement to MERGE target USING source ON [my condtion] WHEN NOT MATCHED BY TARGET THEN IN...

Is it possible to disable echoing query results to stdout in MySQL client?

I am using MySQL client interactively from a remote host. Is there anyway to mute the output of queries and save the output to a file instead? Using tee command in MySQL can save the output to a file but can't disable echoing. ...

C++/Qt Multiline strings; also, multiple queries

Hello, Two [hopefully] quick questions regarding C++/Qt. Is the following proper for writing a string on multiple lines? QString strQuery; strQuery="\ CREATE TABLE foo\ (bar integer primary key,\ baz varchar(20))"; I believe this is right, but in Qt Creator it doesn't highlight as though it is one ...

convert sql query for different database

Is there a tool to convert form one sql query of one Database to another . > eg for sqite CREATE TABLE ConstantValues( Id int > AUTOINCREMENT primary key , > VariableName varchar(50) , Values > varchar(150) ) for sqlserver > CREATE TABLE ConstantValues( Id > INTEGER identity(1,1) primary key , > VariableName varcha...