query

using select query convert columns data as particular column

using select query convert columns data as particular column only using select query ...

How can I make the Count function return 0?

I am trying to create a series of queries in Access that count the number of clients of each ethnicity in each of 77 counties. Here is SQL code for one of my queries that I'm trying to do this for... SELECT [ClientsByCounty-Asian].County, [ClientsByCounty-Asian].CountyName, Count([ClientsByCounty-Asian].Asian) AS CountOfAsian FROM [Cl...

Why is Select 1 faster than Select count(*)?

In Oracle, when querying for row existence, why is Select 1 fast than Select count(*)? ...

MS Access selecting records with a variable

We are trying to make a query that has the user enter a date and the query pulls all records according to that date. In the Design View of the query we have tried [Enter Date] in criteria but it will not pull because it will match the date but not time. I have seen lots of dates formatted with ## marks to ignore the time yet I do not kno...

sum in query / subquery

Table has the following info: date |vendor|sales|percent| -------------------------- 2009-03-03| 10 |13.50| 1.30 | 2009-03-10| 10 |42.50| 4.25 | 2009-03-03| 21 |23.50| 2.30 | 2009-03-10| 21 |32.50| 3.25 | 2009-03-03| 18 |53.50| 5.30 | 2009-03-10| 18 |44.50| 4.45 | I want it to sort into separate tables depending on d...

Limiting the results in IIS index catalog querying

I am using IIS index service to have a search feature in my website. I used the below code to build the query for results string query = String.Format(@"SELECT Rank, VPath, DocTitle, Filename, Characterization, Write FROM SCOPE('DEEP TRAVERSAL OF ""{0}""') WHERE NOT CONTAINS(VPath, '""_vti_"" OR "".pdf"" OR "".config"" OR "".js"" OR...

How to select first 'N' records from a database containing million records?

I have an oracle database populated with million records. I am trying to write a SQL query that returns the first 'N" sorted records ( say 100 records) from the database based on certain condition. SELECT * FROM myTable Where SIZE > 2000 ORDER BY NAME DESC Then programmatically select first N records. The problem with this approac...

Map entity using query in Hibernate

consider table sales (id, seller_id, amount, date) and here is a view that is generated from sales using query SELECT seller_id, SUM(amount) FROM sales GROUP BY seller_id total_sales (seller_id, amount) I want to make an entity for total sales but without the view on the sql side. This entity will be constructed from a query. The ...

Doctrine query memory usage

Doctrine appears to be taking well over 4MB of RAM to execute a single, simple query: print memory_get_peak_usage()." <br>\n"; $q = Doctrine_Query::create() ->from('Directories d') ->where('d.DIRECTORY_ID = ?', 5); $dir = $q->fetchOne(); print $dir['name']." ".$dir['description']."<br>\n"; print memory_get_peak_usage()." <br>\...

Querying data based on 3rd level relationship in CakePHP

I have the following relationships set up: A HABTM B B belongsTo C C hasMany B Now, for a given A, I need all C with the B's attached. I can write the SQL queries, but what's the proper CakePHP way? What method do I call on which model, and with which parameters? ...

SQL query with 2 grouping

This is a query that is executed without problem with MySql 5.0.51: SELECT cc_split.idSplit, count( voteup.vote), count( votedown.vote) FROM cc_split LEFT JOIN cc_split_usager AS voteup ON voteup.idSplit = cc_split.idSplit AND voteup.vote >0 LEFT JOIN cc_split_usager AS votedown ON votedown.idSplit = cc_split.idSplit...

get row no through mysql query

hello sir How to get the row no through mysql query for each row? (i want to display sno) Please help me sir ...

getting charconversion exception for " %" value in query parameter?

i am getting adding some of parameter in query string.value of these param can be "a%%","%" etc.on java code side .while parsing query parameter i m getting char conversionexception as shown below in exception log. 13:14:39,555 ERROR [STDERR] java.io.CharConversionException: EOF 13:14:39,555 ERROR [STDERR] at org.apache.tom...

query result alias

Hi I've a query like this select * from emplyees result is name dept status emp1 Admin y emp2 admin n I'm going to bind it to gridview like mygridview.datasource = ds; now here i want to display approve instead of y and disapprove instead of n how can i write a query ? thank you ...

Linq expression subsonic 3.0.0.3

Hello, I want to 'build' a combined query for Subsonic 3.0.0.3, what is the best way for this? I tried; Expression<Func<Person, bool>> exp = p => true; Expression<Func<Person, bool>> fContinent = p => p.ContinentID == 1; Expression<Func<Person, bool>> fType = p => p.TypeID == 1; exp = Expression.Lambda<...

How to convert access query to sql server query string?

how to converse access query to sql server query string by programing? example for access query string SELECT dbo_VNMST.VISITDATE, dbo_VNTREAT.TREATMENTCODE, dbo_VNMST.HN, dbo_VNMST.VN, dbo_VNTREAT_1.TREATMENTCODE, Count(dbo_VNMST.HN) AS CountOfHN, dbo_PATIENT_NAME.SUFFIX, Mid([firstname],2) AS FIRSTNAME1, Mid([lastname],2) AS LASTNAM...

nHibernate Criteria query with missing mapping

Hi, I'm trying to do the following thing: ICriteria criteriaSelect = session .CreateCriteria(typeof(Employees)) .CreateCriteria("Orders") ; var test = criteriaSelect.List(); With: public class Orders{ public virtual int OrderID { get; private set;} } public c...

How to use flags enums in Linq to Entities queries?

Hi, I have a [Flags] enum like this: [Flags] public enum Status { None = 0, Active = 1, Inactive = 2, Unknown = 4 } A Status enum may contain two values such as: Status s = Status.Active | Status.Unknown; Now I need to create a linq query (LINQ to ADO.NET Entities) and ask for records whose status is s above, that is Acti...

Multiple MySQL queries with Ruby

Hi, I'm having troubles with MySQL queries in Ruby. I use 'mysql' gem. Configuration is stored in a separate yml file and loaded into @conf variable. This is my code: # connect to the database Mysql::new(@conf['sql_host'], @conf['sql_user'], @conf['sql_password'], @conf['sql_base']) # it's ok when we're doing this my.query("SELECT * ...

SQL Query (maybe simple)

Hi folks, So i'm having this problem. I have two tables (Oracle), one is called Destination and the other one Reserve. Reserve has a foreign key to the id of Destination (Because on reserve has one destination). And reserve tuples means all the reserves that all the users have done. I need a way to check the top 3 most visited Destinat...