query

Group and concatenate many rows to one

I want to "concatenate" all the "Text"-rows into one single row and get one row as a result. Is this even possible? I use MSSQL Server 2005. ...

AppEngine: Query datastore for records with no condition for a specific property

i want to do a query that a user may or may not select a filter, but i don't want to create 2 indexes (tables). value=self.request.get('filter') if value: results=Entity.all().filter('p1 =','v1').filter('p2 =','v2').filter('filter_property =',value) else: results=Entity.all().filter('p1 =','v1').filter('p2 =','v2') i could ord...

MySql: remove table rows depending on column duplicate values?

I have a table with year column and this column shouldn't have duplicate values. So I end up with a table with only one 2007 year record for example. So how could I delete those rows that have duplicate year value? Thanks ...

Convert database field to time format

I'm trying to make my string a nice formatted time but the column in the database isn't set up as a date/time field is there anyway I can do this? Here's my query Dim query as String = "Select * from openquery (devbook, 'SELECT wb.arrival_time FROM web_bookings wb ')" And here's where i'm converting it Session("formattime") = DateTi...

Sharepoint 2007 CAML - join Lists in one Query?

Hi, Does anyone know of a method to Query / Join multiple Lists in Sharepoint 2007 via a CAML query? I have found lots of posts saying it's not possible, and found one post indicating that it is, if a Linked source is created: http://blah.winsmarts.com/2007-10-Performing_joins_between_SharePoint_lists.aspx Do anyone know if this is p...

MySQL Query sometime OK, other times takes 5 min!

Hi, I have a table I use for high scores of an iPhone game. As of now the query is disabled so gamers are not able to see scores :-( Table has the following fields: Type Collation Attributes Null Default Extra Action id int(11) No auto_increment date date No ...

sql query problem

i want to compare two date and time with each other and i want to select records that "StartTime" is greater than now time and the "StartDate" is greater than now date. but output is not correct.thanks in advance. my tabale'records are: StartDate StartTime ------------------------------- 1389/07/11 11:04 1389/06/23 21:17 1389/...

Finding missing tables to avoid cross joins

Hi, the user in my application can choose freely some fields from the database. people + peopleid + peoplename cars + carid + carnumber + carcolor pers_car + carid + peopleid Lets assume the user is selecting the fields peoplename and carcolor to find out which person likes which colours. Is it possible to identify the missing per...

MySQL joins for friend feed

Hi everyone, I'm currently logging all actions of users and want to display their actions for the people following them to see - kind of like Facebook does it for friends. I'm logging all these actions in a table with the following structure: id - PK userid - id of the user whose action gets logged actiondate - when the action happe...

MySQL greatest-n-per-group trouble

Hey everyone. I believe this is a 'greatest-n-per-group' question but even after looking at several questions on StackOverflow, I'm unsure how to apply this to my situation... I'm using a MySQL database and have a basic blog-type system set up about Computer Applications... The tables look like this: POSTS post_id post_created post_t...

[beginner question] get data form 'dictionary' table

I have two tables in database: A: [ ID, name, SECRET_KEY] examplary rows: ID1, John, X ID2, Jane, Y and second ( 'dictionary') B: [SECRET_KEY, explanation] like: X, Driver Y, Doctor i want to list all records from table A but with secret_key translated to it's explanation ( based on relation from table B). expected result: ...

Tradeoffs using NHibernate 3.0 QueryOver or LINQ provider

I have not found a clear comparison of what is supported with the NHibernate 3.0 LINQ Provider compared to using the QueryOver syntax. From the surface, it seems like two large efforts into two very similar things. What are the key trade offs to using each? ...

Tricky MS Access SQL query to remove surplus duplicate records

I have an Access table of the form (I'm simplifying it a bit) ID AutoNumber Primary Key SchemeName Text (50) SchemeNumber Text (15) This contains some data eg... ID SchemeName SchemeNumber -------------------------------------------------------------------- 714 Malcolm ...

SQLite queries failing in Android

If I use the query to return some basic columns in table, that is OK. But if I use group by, order by , sum(column) or choose specified columns, the query fails to run. I use Cursor query method or rawquery, both the same. If I run the following queries in adb shell, it works without problems. select * from table (work) select fielda,...

How can I select the latest of three value types in a MySQL database?

Here is an example table: ID time data type 0 0100 xyz 0 1 0200 xyz 1 2 0300 xyz 1 3 0400 xyz 2 4 0200 xyz 0 5 0500 xyz 2 6 0300 xyz 0 Data is added based on timestamp so that the last of each type has the latest time stamp. I would like the result of a SELECT to b...

How to optimize a query that's using group by on a large number of rows

The table looks like this: CREATE TABLE `tweet_tweet` ( `id` int(11) NOT NULL AUTO_INCREMENT, `text` varchar(256) NOT NULL, `created_at` datetime NOT NULL, `created_date` date NOT NULL, ... `positive_sentiment` decimal(5,2) DEFAULT NULL, `negative_sentiment` decimal(5,2) DEFAULT NULL, `entit...

MS Access sum of related records

I have a purchase form that has a continuous subform which shows line items for that purchase. Each line item needs to include a text box that shows the sum for a number of related records in a table for that line item. (Each line item is allocated for a specific purpose(s). For instance, a line item says that 100 widgets are ordered;...

T-SQL between periods gaps

Hi, I have some data on my table like: DAY | QTY | Name 1/1/2010 | 1 | jack 5/1/2010 | 5 | jack 2/1/2010 | 3 | wendy 5/1/2010 | 2 | wendy my goal is to have a SP requesting a period of time (example: '2010-1-1' to '2010-1-5'), and get no gaps. Output example: DAY | QTY | Name 1/1/2010 | 1 | jack 2/1/2010 | 0 |...

How to disable Google Instant Search from within http url query?

Some of my programs send direct queries to Google and then parse the HTML results - for instance http://www.google.com/search?q=foobar&hl=en&num=20. Unfortunately, it seems that since very recently, when sending such queries to Google, the "num" parameter is ignored because of Instant Search. No matter what, only 10 results are ...

nested if statement in query

(please excuse that I didn't use aliases). I would like my query output to say "none" if 3rd qrtr sales equals 4th quarter sales, but my output is just saying "up" when they equal each other. Please help me correct this code trend: IIf([qryQuarterlyCustomersales3rdQuarter_final] .[3rd qrtr sls]=[qryQuarterlyCustomersales4thQuarter_fi...