query

How to construct this query? (Ordering by COUNT() and joining with users table)

users table: id-user-other columns scores table: id-user_id-score-other columns They're are more than one rows for each user, but there's only two scores you can have. (0 or 1, == win or loss). So I want to output all the users ordered by the number of wins, and all the users ordered by the numbers of losses. I know how to do this...

SQL count NULL cells

Dear All, I have the following problem. I have a table in a db, with many columns. I can do different kind of select queries, to show, for example, for each record that satisfies a condition: all cells from columns with names ending in _t0 all cells from columns with names ending in _t1 ... To get the column lists to form the querie...

is there a tool to see the difference between two database tables in SQL Server?

What is a good tool to see the differences between 2 tables (or even better, the datasets returned by 2 queries). EDIT: I'm not interested in the schema changes. Just assume that the schemas are the same. background as to why: I'm porting some legacy code which can fill a database with some pre-calced data. The easiest way to see if I ...

SQL Server Database query help

Possible Duplicate: SQL Server Database query help Hi, I have a problem that I didn't manage to solve for a very long time, and I quite desperate. I have a Database (SQL Server) with table named 'ProcessData' and columns named 'Process_Name' (Data Type: nvarchar(50)), 'Start_At' (DataType: DateTime) and 'End_At' (Data Type...

Get original query from Django

Hi, I would like to get the original query (in the exact same format as sent) from Django. Currently, django sends me a query dict object, wherein if I do querydict.urlencode(), I get the query back, but in a different format from what is sent, since dictionary mangles the positions. For GET, we can use, request.get_full_path(). I ha...

SQL Query Count on Column Information

Using MySQL 5 with table "abrechnung" id datum title betrag wal jon al ben 7 2010-02-08 Essen 1362 0 0 1 0 8 2010-02-15 Essen 324 0 0 1 2 9 2010-02-15 Essen 5732 0 0 1 2 10 2010-02-15 Essen 3245 0 2 1 2 What I want in the end is: Each rows "betrag" is divided thro...

XPath query to select all href attributes of <a> tag, which 'class' attribute equals specified string

I don't know why following query doesn't work: //a/@href[@class='specified_string'] ...

Linq to XML query date intervals

Hi, i am using a large xml file having in the following format: <Sales> <Sale> <Date>04/20/2010</Date> <Time>18:17:29</Time> <Id>P00000001</Id> <Name>Prod Name</Name> <Description>Prod Desc</Description> <Category>Prod Category</Category> <Subcategory>Prod Subcategory</Subcategory> <Size>Prod Size</Si...

Excel > Microsoft Query > SQL Server > Multiple Parameters

Hi, Im relatively new to sql server and excel/microsoft query, I have a query like this Select ...[data]...B1.b,B2.b,B3.b From TABLEA Inner join ( SELECT ---[data]...sum(...) as b From TABLEB WHERE Date between [startdate] and [enddate] ) as B1 Inner join ( SELECT ---[data]...sum(...) as b From TABLEB WHERE Date between [startdat...

SQL Query Math Gymnastics

I have two tables of concern here: users and race_weeks. User has many race_weeks, and race_week belongs to User. Therefore, user_id is a fk in the race_weeks table. I need to perform some challenging math on fields in the race_weeks table in order to return users with the most all-time points. Here are the fields that we need to m...

(self,left outer,right outer,full outer) join - real world examples

can you tell me simple real-world examples for (self,left outer,right outer,full outer) join? ...

Why does this properly escaped SQL query fail?

Here's the query: INSERT INTO jobemails (jobid, to, subject, message, headers, datesent) VALUES ('340', '[email protected]', 'We\'ve received your request for a photo shoot called \'another\'.', 'message', 'headers', '2010-04-22 15:55:06') The datatypes are all correct, it always fails at the subject, so it must be how I'm escaping the ...

Is there a way to rewrite the SQL query efficiently

hi, I have two tables with following definition TableA TableB ID1 ID2 ID3 Value1 Value ID1 Value1 C1 P1 S1 S1 C1 P1 S2 S2 C1 P1 S3 S3 C1 ...

Rails - Select a specific record from model (Checkbox) and displaying it

Hello I'm using ryan Bates railscast on HABTM checkboxes.... I looking for the way to call a specific record from the set, allow me to explain. In my view I have <% for interest in Interest.find(:all) %> <div> <%= check_box_tag "user[interest_ids][]", interest.id, @user.interests.include?(interest) %> <%= interest.name %> </di...

count total records after groupBy select

Hello, I have a mysql select query that has a groupBy. I want to count all the records after the group by statement. Is there a way for this directly from mysql ? thanks. ...

Entity Framework query

Hi all, I have a piece of code that I don't know how to improve it. I have two entities: EntityP and EntityC. EntityP is the parent of EntityC. It is 1 to many relationship. EntityP has a property depending on a property of all its attached EntityC. I need to load a list of EntityP with the property set correctly. So I wrote a piece ...

ROWID (oracle) - any use for it ?

My understanding is that ROWID is a unique value for each row in the result returned by a query. why we need this ROWID ?( there is already ROWNUM is ORACLE). Have any one used ROWID in sql query? ...

SQL grouping query question; evaluating a group of rows based on the value of one field.

I've got table vendorparts that lists all my parts and their vendor(s). Parts with multiple vendors have multiple records in this table. I'm trying to write a query that only returns the partid, and vendor of parts that do not have a default vendor assigned. Partid Vendor Defaultflag 1 A 1 2 B ...

Oracle command hangs when using view for "WHERE x IN..." subquery

I'm working on a web service that fetches data from an oracle data source in chunks and passes it back to an indexing/search tool in XML format. I'm the C#/.NET guy, and am kind of fuzzy on parts of Oracle. Our Oracle team gave us the following script to run, and it works well: SELECT ROWID, [columns] FROM [table] WHERE ROWID IN ( ...

How to pass output of a linq query to another form in C#

I have a Linq query and I want to pass the ouput (userid) to another form for further processing. var userid = from auser in allusers.Users where auser.Username == nameString select new { id = auser.UserId }; so only 'UserId' is stored in variable 'userid' and I want to use this value in another form. Is there any way we can ...