case

about the braces in case statement in switch

♀尐吖头ヾ 提交于 2019-12-06 09:43:27
问题 today while i was trying to write a code to just add & subtract the two 2*2 matrices, in which i used switch statement, i got an error case bypass initialization of local variable in function main() #include <iostream.h> #include <conio.h> #include <string.h> int main() { int mat1[2][2], mat2[2][2], mat3[2][2]; cout << "Enter the elements in the first matrix"; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { cin >> mat1[i][j]; } } cout << "\n\nEnter the elements of the second

What is better, dynamic SQL or where case?

可紊 提交于 2019-12-06 09:12:36
I need to create a stored procedure which takes 12 arguments and the query is filtered with a different combination of this arguments. All 12 arguments are not mandatory as if I pass 3 or 5 or 12 arguments depends on search inputs entered by user. I can create 2 ways, either using a dynamic SQL query or using 'Case where' statements. Example of these queries are as below: Dynamic Query DECLARE @sql VARCHAR(MAX) DECLARE @condition VARCHAR(MAX)='' Declare @var1 varchar(10) Declare @var2 varchar(10) Declare @var3 varchar(10) SET @sql='SELECT * FROM TableDemo1 TD1 WITH(NOLOCK) INNER JOIN

SQL Conditional JOIN column [duplicate]

拈花ヽ惹草 提交于 2019-12-06 08:54:14
问题 This question already has answers here : SQL Conditional AND (4 answers) Closed 5 years ago . I want to determine the JOIN column based on the value of the current row. So for example, my job table has 4 date columns: offer_date, accepted_date, start_date, reported_date. I want to check against an exchange rate based on the date. I know the reported_date is never null, but it's my last resort, so I have a priority order for which to join against the exchange_rate table. I'm not quite sure how

Use Boolean algebra in tsql to avoid CASE statement or deal complex WHERE conditions

余生颓废 提交于 2019-12-06 08:42:30
问题 I came across a scenario,I will explain it with some dummy data. See the table Below Select * from LUEmployee empId name joiningDate 1049 Jithin 3/9/2009 1017 Surya 1/2/2008 1089 Bineesh 8/24/2009 1090 Bless 7/15/2009 1014 Dennis 1/5/2008 1086 Sus 9/10/2009 I need to increment the year column by 1, only If the months are Jan, Mar, July Or Dec. empId name joiningDate derived Year 1049 Jithin 3/9/2009 2010 1017 Surya 1/2/2008 2009 1089 Bineesh 8/24/2009 2009 1090 Bless 7/15/2009 2010 1014

mysql case in update statement with REPLACE

有些话、适合烂在心里 提交于 2019-12-06 08:36:54
问题 I currently have something like this: UPDATE table1 SET column1 = REPLACE(column1, 'abc', 'abc1') WHERE column1 LIKE '%abc%'; UPDATE table1 SET column1 = REPLACE(column1, 'def', 'def1') WHERE column1 LIKE '%def%'; I am trying to consolidate these into a single update statement and am trying the following: UPDATE table1 SET column1 = CASE WHEN column1 LIKE '%abc%' THEN REPLACE(column1, 'abc', 'abc1') WHEN column1 LIKE '%def%' THEN REPLACE(column1, 'def', 'def1') ELSE column1 END; Is this the

How to proceed through all cases if they are true PHP

拈花ヽ惹草 提交于 2019-12-06 05:15:14
问题 I want to know if there is a way to proceed through all three cases,if they are all true,but with using break,because as an example,if the first case is true,the second case is false and the third is also false,and i am not using break,it will procced trough all anyway.Change the strtotime with 6 October 2014,and you will see what i mean $date = strtotime("1 October 2014"); switch($date) { case (date('l', $date) == 'Monday'): //case 1: If the current day is Monday echo "weekly<br>"; break;

NHibernate QueryOver CASE WHEN calculate on column value

五迷三道 提交于 2019-12-06 04:24:29
问题 I have been trying to do the following T-SQL in NHibernate QueryOver, but have not succeeded: SELECT Id, SUM(CASE MyValue WHEN 1 THEN Volume ELSE Volume * -1 END) FROM MyTable GROUP BY Id I am trying to sum up all Volume, but for MyValue=1 should be positive values otherwise negative values. So far I got: var result = this.Session.QueryOver<MyTable>() .Select(Projections.Group<MyTable>(x => x.Id), Projections.Conditional(Restrictions.Eq(Projections.Property<MyTable>(x => x.MyValue), '1'),

SET in combination with CASE statement in cypher

不羁的心 提交于 2019-12-06 02:23:45
问题 I am tryin to set two different relationship properties to a count, with a case construct depending on the value of another relationship property. There is a console at http://console.neo4j.org/?id=rt1ld5 the cnt column contains the number of times r.value occurs. The two first rows of the initial query in the console indicate that the term "Car" is linked to 1 document that is considered relevant, and to two documents that are considered not relevant. I want to SET a property on the [

Simple way to create possible case

随声附和 提交于 2019-12-06 01:23:28
I have lists of data such as a = [1,2,3,4] b = ["a","b","c","d","e"] c = ["001","002","003"] And I want to create new another list that was mixed from all possible case of a,b,c like this d = ["1a001","1a002","1a003",...,"4e003"] Is there any module or method to generate d without write many for loop? Ignacio Vazquez-Abrams [''.join(str(y) for y in x) for x in itertools.product(a, b, c)] This is a little simpler to do if you convert a to be a list of str too. and saves needlessly calling str() on each element of b and c >>> from itertools import product >>> a = [1,2,3,4] >>> b = ["a","b","c",

Case Statement with different data type

南楼画角 提交于 2019-12-05 22:08:44
I am trying to return SLA days for particular conditions. However for a specific condition I want it to return a different data type. Current code is as follows: SELECT CASE WHEN fourthlevel.case_type IN ('Complaint') THEN (SELECT COUNT (*) FROM work_days1 WHERE work_days1.business_date > fourthlevel.cdate AND work_days1.business_date <= COALESCE (fourthlevel.close_date, SYSDATE)) WHEN fourthlevel.case_type IN ('Enquiry') THEN (SELECT COUNT (*) FROM work_days1 WHERE work_days1.business_date > fourthlevel.create_date AND work_days1.business_date <= COALESCE (fourthlevel.close_date, SYSDATE))