Search Results

Search found 1369 results on 55 pages for 'over clause'.

Page 8/55 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Split function in where clause

    - by abhishek-khandelwal
    hello friends I am using following query in linq In product table following type of data are stored abc-def bcd=fgh abc-xyz var query=from prod in db.Product join cat in db.category on prod.categoryId=cat.categoryID where prod.productName.split('-')[0]=="abc" but in that query it product annoumous problem Please give some suggestion to split in where caluse

    Read the article

  • DB2 SQL count in join or where clause

    - by Pat
    This is probably an amateur question but I'm an amateur ! ;o) I have several tables: Account table, Officer table, Location table, Web table... The Officer table doesn't give me the number of officers per account. I need to retrieve only the accounts that have more than 20 officers. Should I use the COUNT ? If so, how ? Your help is greatly appreciated. Thanks. Pat

    Read the article

  • SQL Having Clause

    - by Wally
    I'm trying to get a stored procedure to work using the following syntax: select count(sl.Item_Number) as NumOccurrences from spv3SalesDocument as sd left outer join spv3saleslineitem as sl on sd.Sales_Doc_Type = sl.Sales_Doc_Type and sd.Sales_Doc_Num = sl.Sales_Doc_Num where sd.Sales_Doc_Type='ORDER' and sd.Sales_Doc_Num='OREQP0000170' and sl.Item_Number = 'MCN-USF' group by sl.Item_Number having count (distinct sl.Item_Number) = 0 In this particular case when the criteria is not met the query returns no records and the 'count' is just blank. I need a 0 returned so that I can apply a condition instead of just nothing. I'm guessing it is a fairly simple fix but beyond my simple brain capacity. Any help is greatly appreciated. Wally

    Read the article

  • WHERE clause confusion with PDO

    - by Greg
    I'm having some trouble understanding how to use prepared statements, when you need to match one value against several columns at once. In other words what instead of doing this: $stmt = $dbh-prepare("SELECT * FROM REGISTRY where name = ?"); $stmt-bindParam(':name', $name); I wanted to do this: $stmt = $dbh-prepare("SELECT * FROM REGISTRY where firstname = ? or lastname = ?"); with both '?' representing the same string.

    Read the article

  • switch case in where clause

    - by Nimesh
    hi, i need to check three conditions: if @filter = 1 { **select * from employeestable where rating is not null** } else if @filter = 2 { **select * from employeestable where rating is null** } else { **select * from employeestable** } This i need to do using a case statement. now i have more than 30 lines of query, if i use case i can reduce my code upto 70% Please let mek now how can i do this.

    Read the article

  • Union on two tables with a where clause in the one

    - by Lostdrifter
    Currently I have 2 tables, both of the tables have the same structure and are going to be used in a web application. the two tables are production and temp. The temp table contains one additional column called [signed up]. Currently I generate a single list using two columns that are found in each table (recno and name). Using these two fields I'm able to support my web application search function. Now what I need to do is support limiting the amount of items that can be used in the search on the second table. the reason for this is become once a person is "signed up" a similar record is created in the production table and will have its own recno. doing: Select recno, name from production UNION ALL Select recno, name from temp ...will show me everyone. I have tried: Select recno, name from production UNION ALL Select recno, name from temp WHERE signup <> 'Y' But this returns nothing? Can anyone help?

    Read the article

  • Insert statement with where clause.

    - by debraj
    I had a table with unique Date_t1 date type field, but in Table description field is not mentioned as unique, now while inserting new row i need to validate if date exist or not, If already exist i should not allow to make changes on that row, neither a new row needs to be created, Any idea how to resolve this problem in efficient way,

    Read the article

  • T-SQL: Dynamic Where clause in normal SQL statement

    - by Torben H.
    Hey there, I looking for a way to dynamicly add a filter to my statment without using dynamic SQL. I want to select all computers from a table, but when I pass a computer id to the sp, I want to get only this computer. Actually I try this on DECLARE @ComputerFilter AS INT DECLARE @ComputerID AS INT SELECT Computername FROM Computer WHERE (ComputerID = @ComputerID) OR (@ComputerFilter IS NULL)) But this is 100 times slow then this statment and tooks as long as SELECT * FROM Computer SELECT Computername FROM Computer WHERE ComputerID = @ComputerID Is there a way to speed this statment up or is there any other way to solve this problem with one select und without dynamic sql?

    Read the article

  • T SQL WHERE Clause

    - by johniom
    Hiya Guys, I'm trying to develop some code which pulls latest informtion only. What it is when a user goes into a form there a subtable and everytime they change something it creates a new row in the colum called type12_OriginalNoteID which puts its own unquie number in. Another feild called type12_OriginalNoteID keeps the same number - which keeps track of what the oringal number was before any changes were made. I do have some code which does pull the latest information but it does not pull anything if the user has not made any changes to the form - and thats because the type12_OriginalNoteID is null. The code is as follows ea.type12_NoteID IN (SELECT TOP 1 ea.type12_NoteID FROM UserAssessv1aidsadaptations ea1 WHERE ea.type12_NoteID = ea1.type12_OriginalNoteID ORDER BY ea.type12_UpdatedDate DESC) An example of the data is as follows :- type12_note ID - 12 type12_OriginalNoteID NULL type12_UpdatedDate - 11/03/2010 What would be the solution to show the ifnroamtion if no one has made any changes to the subtable? - adding an if statement to run if type12_OriginalNoteID is null??

    Read the article

  • SQL Where clause in ORACLE

    - by ArneRie
    Hi, does someone has an idea, how to get END_DATE / START_DATE where TO_DATE('06/1/2010','MM/DD/YYYY') ? SELECT "PROJECT"."ID", "PROJECT"."CLIENT", "PROJECT"."NAME", "PROJECT"."STATE", "PROJECT"."EARLIEST_START", "PROJECT"."LATEST_END", "PROJECT"."EFFORT", "PROJECT"."LINK", "PROJECT"."STATUS", "PROJECT"."DESCRIPTION", (SELECT SUM((END_DATE - START_DATE + 1) * (WORKLOAD / 100)) FROM WORKITEM WHERE PROJECT = PROJECT.ID ) AS "P_A", (SELECT COUNT(*) FROM PUBLIC_HOLIDAY WHERE HOLIDAY_DATE BETWEEN TO_DATE('06/1/2010','MM/DD/YYYY') AND TO_DATE('06/2/2010','MM/DD/YYYY')) AS P_B, "PROJECT_STATE"."STATE", "PERSON"."DISPLAY_NAME" AS "RESPONSIBLE" FROM "PROJECT" INNER JOIN "PROJECT_STATE" ON PROJECT.STATE = PROJECT_STATE.ID INNER JOIN "PERSON" ON RESPONSIBLE = PERSON.ID WHERE (PROJECT.CLIENT = '1') AND (PROJECT.STATE = 1) ORDER BY "PROJECT"."NAME" ASC

    Read the article

  • How to do a Postgresql subquery in select clause with join in from clause like SQL Server?

    - by Ricardo
    I am trying to write the following query on postgresql: select name, author_id, count(1), (select count(1) from names as n2 where n2.id = n1.id and t2.author_id = t1.author_id ) from names as n1 group by name, author_id This would certainly work on Microsft SQL Server but it does not at all on postegresql. I read its documentation a bit and it seems I could rewrite it as: select name, author_id, count(1), total from names as n1, (select count(1) as total from names as n2 where n2.id = n1.id and n2.author_id = t1.author_id ) as total group by name, author_id But that returns the following error on postegresql: "subquery in FROM cannot refer to other relations of same query level". So I'm stuck. Does anyone know how I can achieve that? Thanks

    Read the article

  • SQL: join within same table with different 'where' clause

    - by Pmarcoen
    Ok, so the problem I'm facing is this, I have a table with 3 columns : ID, Key and Value. ID | Key | Value ================ 1 | 1 | ab 1 | 2 | cd 1 | 3 | ef 2 | 1 | gh 2 | 2 | ij 2 | 3 | kl Now I want to select the value of Keys 1 & 3 for all IDs, the return should be like this ID | 1 | 2 ================ 1 | ab | ef 2 | gh | kl So per ID 1 row containing the Values for Keys 1 & 3. I tried using 'join' but since I need to use multiple where clauses I can't figure out how to get this to work ..

    Read the article

  • Sqlalchemy complex in_ clause

    - by lostlogic
    I'm trying to find a way to cause sqlalchemy to generate sql of the following form: select * from t where (a,b) in ((a1,b1),(a2,b2)); Is this possible? If not, any suggestions on a way to emulate it? Thanks kindly!

    Read the article

  • Linq to SQL Where clause based on field selected at runtime

    - by robasaurus
    I'm trying to create a simple reusable search using LINQ to SQL. I pass in a list of words entered in a search box. The results are then filtered based on this criteria. private IQueryable<User> BasicNameSearch(IQueryable<User> usersToSearch, ICollection<string> individualWordsFromSearch) { return usersToSearch .Where(user => individualWordsFromSearch.Contains(user.Forename.ToLower()) || individualWordsFromSearch.Contains(user.Surname.ToLower())); } Now I want this same search functionality on a different datasource and want to dynamically select the fields to apply the search to. For instance instead of IQueryable of Users I may have an IQueryable of Cars and instead of firstname and surname the search goes off Make and Model. Basically the goal is to reuse the search logic by dynamically selecting what to search on at runtime.

    Read the article

  • Mysql stored procedure where clause

    - by Mneva skoko
    I am having a problem with this stored procedure: Delimiter // Create procedure(in varchar(50)) Begin Select * from employees where email = eml; End// Delimiter ; I don't get errors when I run this procedure but when i call it in my php script it returns nothing.

    Read the article

  • Updating records in Postgres using FROM clause

    - by Summer
    Hi, I'm changing my db schema, and moving column 'seat' from old_table to new_table. First I added a 'seat' column to new_table. Now I'm trying to populate the column with the values from old_table. UPDATE new_table SET seat = seat FROM old_table WHERE old_table.id = new_table.ot_id; This returns ERROR: column reference "seat" is ambiguous. UPDATE new_table nt SET nt.seat = ot.seat FROM old_table ot WHERE ot.id = nt.ot_id; Returns ERROR: column "nt" of relation "new_table" does not exist Ideas?

    Read the article

  • Linq In Clause & Predicate building

    - by Michael G
    I have two tables. Report and ReportData. ReportData has a constraint ReportID. How can I write my linq query to return all Report objects where the predicate conditions are met for ReportData? Something like this in SQL: SELECT * FROM Report as r Where r.ServiceID = 3 and r.ReportID IN (Select ReportID FROM ReportData WHERE JobID LIKE 'Something%') This is how I'm building my predicate: Expression<Func<ReportData, bool>> predicate = PredicateBuilder.True<ReportData>(); predicate = predicate.And(x => x.JobID.StartsWith(QueryConfig.Instance.DataStreamName)); var q = engine.GetReports(predicate, reportsDataContext); reports = q.ToList(); This is my query construction at the moment: public override IQueryable<Report> GetReports(Expression<Func<ReportData, bool>> predicate, LLReportsDataContext reportDC) { if (reportDC == null) throw new ArgumentNullException("reportDC"); var q = reportDC.ReportDatas.Where(predicate).Where(r => r.ServiceID.Equals(1)).Select(r => r.Report); return q; }

    Read the article

  • Does MySQL short-circuit the ORDER BY clause?

    - by nickf
    Given this SQL: SELECT * FROM mytable ORDER BY mycolumn, RAND() Assuming that mycolumn happens to only contain unique values (and hence, contains enough information to perform the ORDER BY), does MySQL short-circuit the operation and skip evaluating the rest?

    Read the article

  • How does the proc in the caches_action if clause get execute

    - by Sid
    I have a newbie kind of question which I cant get my head around. How does the Proc in the if condition of the caches_action get executed for the caches_action method. for example caches_action :show, :if=Proc.new{|x| something} what i dont get its how does this get called. I know i can execute a proc defined as proc= Proc.new by proc.call so i dont understand how this gets called. Second how do I pass conditions like if logged_in? I'd appreciate any help on this

    Read the article

  • How to combine 2 linq statments with groupby clause into 1

    - by AG.
    Hello Friends, I was wondering if i can consolidate below 2 linq statments into 1 statment. I am sure it should be possible, but various attempts i am unable to manage. var prevProvisionsBySubBook = (from provision in prevProvisions group provision by provision.SubBook into subBookGrouping select new { Key = subBookGrouping.Key, Value = subBookGrouping.Sum(t => t.ProvisionUSD) }); var currentProvisionsBySubBook = (from provision in currentProvisions group provision by provision.SubBook into subBookGrouping select new { Key = subBookGrouping.Key, Value = subBookGrouping.Sum(t => t.ProvisionUSD) }); var adjustmentChangeBySubBook = (from current in currentProvisionsBySubBook select new { Key = current.Key, Value = current.Value - (prevProvisionsBySubBook.Any() ? prevProvisionsBySubBook.Where(t => t.Key == current.Key).Single().Value : 0) }); any help would be apprecaited.

    Read the article

  • Getting the first of a GROUP BY clause in SQL

    - by Michael Bleigh
    I'm trying to implement single-column regionalization for a Rails application and I'm running into some major headaches with a complex SQL need. For this system, a region can be represented by a country code (e.g. us) a continent code that is uppercase (e.g. NA) or it can be NULL indicating the "default" information. I need to group these items by some relevant information such as a foreign key (we'll call it external_id). Given a country and its continent, I need to be able to select only the most specific region available. So if records exist with the country code, I select them. If, not I want a records with the continent code. If not that, I want records with a NULL code so I can receive the default values. So far I've figured that I may be able to use a generated CASE statement to get an arbitrary sort order. Something like this: SELECT *, CASE region WHEN 'us' THEN 1 WHEN 'NA' THEN 2 ELSE 3 END AS region_sort FROM my_table WHERE region IN ('us','NA') OR region IS NULL GROUP BY external_id ORDER BY region_sort The problem is that without an aggregate function the actual data returned by the GROUP BY for a given row seems to be untameable. How can I massage this query to make it return only the first record of the region_sort ordered groups?

    Read the article

  • Enhancing an 'ORDER BY' clause to judge condition by more than 1 integer

    - by Yvonne
    Hi folks, I have some PHP code which allows me to sort a column into ascending and descending order (upon click of a table row title), which is good. It works perfectly for my D.O.B colum (with date/time field type), but not for a quantity column. For example, I have quantites of 10, 50, 100, 30 and another 100. The order seems to be only appreciating the 1st integer, so my sorting of the column ends up in this order: 10, 100, 100, 30, 50... and 50, 30, 100, 100, 10. This is obviously incorrect as 100 is bigger than 50, therefore both 100 values should appear at the end surely? It seems to me that 100 is only being taken into account as having the '1' value, then it appears before 10 because the system recognises it has another 0. Is this normal to happen? Is there any way I can solve this problem? Thanks for any help. P.S. I can show code if necessary, but would like to know if this is a common issue by default.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >