where-clause

SQL sum 2 different column by different condtion then subtraction and add

雨燕双飞 提交于 2020-01-07 05:40:51
问题 what I am trying is kind of complex, I will try my best to explain. I achieved the first part which is to sum the column by hours. example ID TIMESTAMP CUSTAFFECTED 1 10-01-2013 01:00:23 23 2 10-01-2013 03:00:23 55 3 10-01-2013 05:00:23 2369 4 10-01-2013 04:00:23 12 5 10-01-2013 01:00:23 1 6 10-01-2013 12:00:23 99 7 10-01-2013 01:00:23 22 8 10-01-2013 02:00:23 3 output would be Hour TotalCALLS CUSTAFFECTED 10/1/2013 01:00 3 46 10/1/2013 02:00 1 3 10/1/2013 03:00 1 55 10/1/2013 04:00 1 12 10/1

MySQL Returns All Rows When field = 0

冷暖自知 提交于 2020-01-07 05:24:05
问题 I've seen a few questions on here very similar to this however I have not found an answer specific to what I believe my problem to be. I have two tables, subcompanies and presets . The two tables are linked together through an ID, CntRefID and PresetIDFoxPro . I want to select all of the text from the Preset table's text column when the ID's matchup. This works flawlessly when the CntRefID has a number in it. However, if it is 0 then every single field from the presets text column is returned

How to fetch values of column 1 that contain only the given value of column 2?

别来无恙 提交于 2020-01-06 15:59:15
问题 I want to select names that only appear in Mexico and not in any other country. Country | Name -------------|------------ Mexico | Vallejo Mexico | Rachel United States| Rachel UK | Rachel Australia | Rachel Mexico | Amy Canada | Amy Mexico | Annette Mexico | Jennifer Swahili | Jennifer Mexico | Benedict The correct query would only return the following names. Name --------- Annette Benedict Vallejo Any ideas? I'm not sure if this might be a mix of DISTINCT and WHERE conditions. 回答1: I think

What is the right way to add a variable where-clause to this update function

笑着哭i 提交于 2020-01-05 08:09:34
问题 I'm made a database class in php. Now i was testing the update function in it. It returns an syntax error or an unknown column error depending on how the where-clause is formed. I tried: 'woord = \'uiteindelijk\'' and 'woord = \"uiteindelijk\"' and 'woord = "uiteindelijk"' and more I also tried different quotes and backsticks in de functions query but it al gave me the same errors. My question is what is the right way to form the where-clause is this example if it possible ofcourse. And if

Multiple Defered WHERE clause expressions in LINQ to SQL

我是研究僧i 提交于 2020-01-04 14:26:24
问题 Maybe a simple question, I'm trying to get a result from a table where the Name column contains all of an array of search terms. I'm creating a query and looping through my search strings, each time assigning the query = query.Where(...);. It appears that only the last term is being used, I supposed because I am attempting to restrict the same field each time. If I call .ToArray().AsQueryable() with each iteration I can get the cumlative restrinction behavior I'm looking for, but it there an

Laravel multiple where clauses in query from given array

…衆ロ難τιáo~ 提交于 2020-01-02 09:56:08
问题 I hope the title describes my problem good as enough. I tried to make a geosearch-function in laravel. The queries as its own are correct. Now I try to get all articles from my table, whose match with the gotten zipcode of a former query. All functions I use you can found here: Laravel 5 add results from query in a foreach to array). But now I want to perform one query, within multiple or dynamic where clauses (with or). The print_r($zipcodes) of my former query (get all zipcodes in a range

LINQ results when there are no matches?

≡放荡痞女 提交于 2020-01-02 02:42:08
问题 What exactly does a LINQ function return when there are no matches? Take the Where method, for example: var numbers = Enumerable.Range(1, 10); var results = numbers.Where(n => n == 50); What would be in results at this point? 回答1: results itself is just a query. Until you start to iterate through it (either explicitly or via a call like Count() ), nothing has checked whether there are any results or not. It's only when you enumerate it that anything will happen. So you could do: foreach (int

how to add WHERE clause to Query on android

不打扰是莪最后的温柔 提交于 2020-01-01 08:20:49
问题 I would like to limit the results to those whose KEY_HOMEID is equal to journalId. I've been on this for a couple days any help would be appreciated. public Cursor fetchAllNotes(String journalId) { return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_HEIGHT, KEY_BODY, KEY_HOMEID},"FROM DATABASE_TABLE WHERE KEY_HOMEID = journalId",null, null, null, null,null); } 回答1: Have a look at http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#query Your query

How to compare Timestamp in where clause

随声附和 提交于 2020-01-01 06:18:40
问题 I have a table with timestamp column i want to get the values where the timestamp in specific month (for example where the timpestamp between 1 september and 30 septemper) taking in considration if the month is 31 day. I use this query: SELECT users.username, users.id, count(tahminler.tahmin)as tahmins_no FROM users LEFT JOIN tahminler ON users.id = tahminler.user_id GROUP BY users.id having count(tahminler.tahmin) > 0 Can i add where timestamp IN(dates_array) ?? date_array will be the dates

How to compare Timestamp in where clause

徘徊边缘 提交于 2020-01-01 06:18:30
问题 I have a table with timestamp column i want to get the values where the timestamp in specific month (for example where the timpestamp between 1 september and 30 septemper) taking in considration if the month is 31 day. I use this query: SELECT users.username, users.id, count(tahminler.tahmin)as tahmins_no FROM users LEFT JOIN tahminler ON users.id = tahminler.user_id GROUP BY users.id having count(tahminler.tahmin) > 0 Can i add where timestamp IN(dates_array) ?? date_array will be the dates