case

LINQ to SQL With the where with case statement

笑着哭i 提交于 2019-12-08 12:59:31
I have a SQL query that I want to convert into LINQ. I have pulled the data in to datatable.I am quite confused how to write the WHERE part of the query. The condition is dependent on a column in the table, If col_Con is "G" then use greater than on col_Val and 30(any value) else if col_Con is "L" then use less than condition on col_Val and 30(any value) I am using Sqlserver 2005 for the SQL query part . SELECT * FROM Mytable WHERE CASE WHEN col_Con= 'G' THEN col_Val ELSE 30 END <= CASE WHEN col_Con= = 'L' THEN 30 ELSE col_Val END Here is the start of my Linq //Mytable is a DataTable var drs =

How to check multiple columns whether they are empty or not using mysql case

。_饼干妹妹 提交于 2019-12-08 10:39:57
问题 I have a table called purchase_hs and I have different types of level dates and different types of transport modes and quantity like below. Now my requirement is I need to consider only one level date column per row. Suppose if we have level1 and remaining all are empty then we need to add 28 days based on the transport mode ( sea = 28days , air =14 days , truck = 5 days and transport mode is empty then 28 days) and display the level1 date quantity. If we have level1 date and level2 date and

Mysql CASE statement usage with Zend

不羁的心 提交于 2019-12-08 07:37:13
问题 I have the following query that selects some records from the database: $select_person = $this->select() ->setIntegrityCheck(false) ->from(array('a' => 'tableA'), array(new Zend_Db_Expr('SQL_CALC_FOUND_ROWS a.id'), 'a.cid', 'a.email', 'final' => new Zend_Db_Expr( "concat( '<div style=\"color:#1569C7; font-weight:bold\">', a.head , ' ' , a.tail, '</div>')" ), 'a.red_flag' ) ) ->joinLeft(array('b' => 'tableb'), ... blah blah) ->where('blah blah') ->order('a.head ASC') I want to modify the above

T-SQL CASE statement relies on another CASE statement in same SELECT query

拟墨画扇 提交于 2019-12-08 06:46:16
问题 I have a SELECT query where the result of the second CASE statement can depend on the result of the first CASE statement - something like: SELECT ..., CASE WHEN dbo.Table1.Description LIKE '%car%' THEN 'Car' WHEN ... ELSE 'Unclassified' END AS Product, CASE WHEN dbo.Table2.Description LIKE '%my%brand%' THEN 'Branded' WHEN Product='Unclassified' THEN 'Unclassified' ELSE 'Generic' END AS Brand, ... FROM ... Where Brand is 'Unclassified' if the query can't find the brand name in a description

Multiple Insert statements into MySQL Case

假如想象 提交于 2019-12-08 06:01:17
问题 I'm trying to select a value (id) from a MySQL table and use it in a update statement - all in a MySQL query. The select is composed of 2 parts: if the id exists, it is returned; if not, 2 inserts are done and the id is returned. I have the following query: SELECT (CASE a.id WHEN '' THEN ( DELIMITER // INSERT INTO xxxx (item_id, date_created, date_modified) VALUES (3313, NOW(), NOW())// INSERT INTO yyyy (item_id, locale_id, value, date_created, date_modified) VALUES(LAST_INSERT_ID(), 2, TRIM

LINQ to SQL With the where with case statement

假装没事ソ 提交于 2019-12-08 05:46:10
问题 I have a SQL query that I want to convert into LINQ. I have pulled the data in to datatable.I am quite confused how to write the WHERE part of the query. The condition is dependent on a column in the table, If col_Con is "G" then use greater than on col_Val and 30(any value) else if col_Con is "L" then use less than condition on col_Val and 30(any value) I am using Sqlserver 2005 for the SQL query part . SELECT * FROM Mytable WHERE CASE WHEN col_Con= 'G' THEN col_Val ELSE 30 END <= CASE WHEN

SQLite CASE/WHEN statement

十年热恋 提交于 2019-12-08 02:27:44
问题 this is my CASE/WHEN statement. But as you may see I get this error. I don't know why. All I want to do is detect when something in field MAJKA is changed. So if some other fields of column MAJKA are empty don't touch them, but change the value to new value of those fields of column MAJKA which are NOT empty. SQL Error: near "UPDATE": syntax error <CREATE TRIGGER [test] AFTER UPDATE OF [MAJKA] ON [unos_golub] FOR EACH ROW BEGIN SELECT majka, CASE WHEN majka='' THEN (UPDATE unos_golub SET broj

Compare String in Oracle Case When

橙三吉。 提交于 2019-12-08 01:17:59
问题 i have an issue with oracle case when. SELECT CASE WHEN '7C54D3E133830A78E040A8C010014B7D' != '' THEN '7C54D3E133830A78E040A8C010014B7D' WHEN 'e84a4433966c4b8996ce34905acff63d' != '' THEN 'e84a4433966c4b8996ce34905acff63d' WHEN '7faa9126b1c6412fa58375ab2b2be1db' != '' THEN '7faa9126b1c6412fa58375ab2b2be1db' ELSE NULL END FROM DUAL this query always returns null, though it's obvious the result should be the first case. Am i missing something about string comparison in oracle? 回答1: You are

how to search and replace case sensitive string using batch

一笑奈何 提交于 2019-12-07 21:57:55
问题 I want to search and replace case sensitive string like if I have rise Rise RISE in a text file I only want to replace string "rise" the code below is replace all three strings. Kindly help me ! @Echo on SETLOCAL ENABLEEXTENSIONS SETLOCAL DISABLEDELAYEDEXPANSION set file="c:\Users\rawal\Desktop\a\file.txt" set /p Input=Enter some text: set OldStr="rise" set NewStr=%Input% for /f "tokens=1,* delims=]" %%A in ('"type %file% |find /n /v """') do ( set "line=%%B" if defined line ( call echo %

Case label does not reduce to an integer constant in C?

∥☆過路亽.° 提交于 2019-12-07 19:22:51
问题 I am working on a game and I ran my code and got the error "case label does not reduce to an integer constant." I think I know what this means, but how do I fix it? Here is my code: #include<stdio.h> #include<stdlib.h int player_cash[3] = {50}; char job[][20] { 'A', 'B', 'C', "Donate", "Go to work", "Exit" }; int jobs; int main() { while(player_cash[0] > 0) { printf("Please type A, B, C, Donate, Go to work, or Exit\n"); switch(jobs) { case 'A': player_cash[0]-=5; player_cash[1]+=5; printf(