query

How to find similar results and sort by similarity?

How do I query for records ordered by similarity? Eg. searching for "Stock Overflow" would return Stack Overflow SharePoint Overflow Math Overflow Politic Overflow VFX Overflow Eg. searching for "LO" would return: pabLO picasso michelangeLO jackson polLOck What I need help with: Using a search engine to index & search a MySQ...

Help me with this SQL Query...

I've got a SQL Server CE 3.5 table (Transactions) with the following Schema: ID Transaction_Date Category Description Amount Query: SELECT Transaction_Date, SUM(Amount) FROM Transactions GROUP BY Transaction_Date; I'm trying to do a SUM(Amount) and group by transaction_date just so I can get the total amount for each day b...

Tough Mysql Query....

Hi guys. I got a skill test for a quick mysql query. I am given the tables: Orders OrderItems ---------------------------------------- id id date order_id(Orders.id) shipping_amount product_id order_status pr...

SQL - How do you select the first row (or any unique row) of multiple rows with the same ID?

Let's say I have a query result that looks as follows: ID NAME Phone ---- ---- ----- 1 Bob 111-111-1111 1 Bob 222-222-2222 1 Bob 333-333-3333 2 Stan 555-555-5555 3 Mike 888-888-8888 3 Mike 777-777-7777 I want to return just a single row instance of each ID value. It doesn't matte...

A simple MySQL query taking forever (more than 20 minutes!)

Hello, Maybe you can help me. I need to query 3 tables in order to get data for a financial stock. The idea is to go to the instruments table, find the index for each instrument and then bring all the prices for that particular instrument together with the indicators that are on a separate table. Tables stockdata and indicators are bot...

Tough Mysql Query ....

Hi guys, I am trying to do a complex query from two tables...It's a question from a skill quiz.... table **Orders Customer**s id id date first_name shipping_amount last_name order_stat...

Query Object without magic strings

Ok, I have a question. I have 3-tier project. Dal => Domain => UI. design choice is not to expose domain objects (business classes) to the ui, but to use DTO. I am trying to build a Query engine that takes parameters from the ui layer and converts into the NHibernate criteria api on the dal layer. The point is the ui layer does not known...

How to check if a date is in a list of dates - TSQL

I am trying to create a SQL query that checks if a date is in a list of dates but my query doesn't work... SELECT * FROM TABLE1 WHERE field1 = value1 AND convert(nvarchar(15),date_start,101) IN (SELECT convert(nvarchar(15),date_end,101) FROM TABLE2 ) This query should return some values but it doesn't......

SSAS cube creation question - parent/child relationship

I'm currently struggling with the creation of a cube. Below is a simplified version of my relational data... Race Id Type Total 1 A 3 2 A 2 Result Id RaceId Gender Position 1 1 M 2 2 1 M 3 3 1 F 1 4 2 F 2 5 2 F 1 In some...

SQL: need only 1 row per particular timestamp

i have some SQL code that is inserting values from another (non sql-based) system. one of the values i get is a timestamp. i can get multiple inserts that have the same timestamp (albeit different values for other fields). my problem is that i am trying to get the first insert happening every day (based upon timestamp) since a parti...

Limiting query size with entity framework

this is a simple question (I think), but I have not been able to find a solution. I know with other types of queries, you can add a limit clause that makes the query only return up to that many results. Is this possible with an entity query? var productQuery = from b in solutionContext.Version where b.Prod...

Can I retrieve a value from a previous line using CURSORs of SQL?

I'm developing a query, where I need that a certain field of my current line be the result of "the field of my current line" + "the same field of the previous line". (SQL Server 2008) How can I do it by using cursors? ...

Returning related elements in a single query (Is my query bad?)

Hey, I have a table called products that has a relationship with itself. This table stores products, their sub-products, and then sub-sub-products. When a user searches for the top-most product, this query is supposed to return the parent, its children, and its children's children. Now, my query works, but I am new to the entity framewor...

sql query from 3 tables

dear i need to get query from 3 tables i try to show how i need result in picture hope this will explain every thing. ...

Nhibernate - How do I get ordered distinct results with QueryOver?

public class City { virtual public long Id { get; set; } virtual public string Name { get; set; } } City table contains duplicated Names and I want to remove duplicates. I also want the results to be ordered by Id. First I thought about the following query. select distinct Name from City order by Id; But this breaks with 'O...

FULL OUTER JOIN or UNION ?

Hi, confused how to achieve this maybe with FULL OUTER or a UNION. I want to join results in such a way that Table1 Table2 --------------- ----------------- ID Name Salary ID Fruits --------------- ----------------- 1 John 1000 1 Apples 1 Henry 4000 ...

Querying an HTML page with XPath in Java

Hi, Can anyone advise me a library for Java that allows me to perform an XPath Query over an html page? I tried using JAXP but it keeps giving me a strange error that I cannot seem to fix (thread "main" java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd). Thank...

help to write a query statement

I need a query statement written such that it searches three tables table 1 id fullname active table 2 id fullname table 3 id fullname I wanted this query to search all three tables combine and give me the result for those id fullname that is not active ...

Count associations in sqlite database query?

I have a sqlite database with three tables: Notes, Lists, and Notes-in-Lists. Both Notes and Lists have an autogenerated id column and some extra data columns like title. Notes-in-Lists is an association table with an autokey, and two foreign keys that point to a Note id and a List id. I have a query that returns all notes in a given l...

Codeigniter num_row returns "array" instead of number

Alright, Im trying to count all the rows where "Membership_Status" = Active. The result I get right now is "Array" instead of a number. Here is my model class Report_model extends Model { function count_members() { $query = $this->db->get_where('Membership', array('Membership_Status' => 'Active')); return $query->num_rows(); } ...