case

Case statement in MySQL

南笙酒味 提交于 2019-12-17 08:29:47
问题 I have a database table called ' tbl_transaction ' with the following definition: id INT(11) Primary Key action_type ENUM('Expense', 'Income') action_heading VARCHAR (255) action_amount FLOAT I would like to generate two columns: Income Amt and Expense Amt . Is it possible to populate the columns conditionally, using only a SQL Query, such that the output appears in the correct column, depending on whether it is an Expense item or an Income item? For example: ID Heading Income Amt Expense Amt

How can I have lowercase routes in ASP.NET MVC?

人盡茶涼 提交于 2019-12-17 04:37:19
问题 How can I have lowercase, plus underscore if possible, routes in ASP.NET MVC? So that I would have /dinners/details/2 call DinnersController.Details(2) and, if possible, /dinners/more_details/2 call DinnersController.MoreDetails(2) ? All this while still using patterns like {controller}/{action}/{id} . 回答1: With System.Web.Routing 4.5 you may implement this straightforward by setting LowercaseUrls property of RouteCollection: public static void RegisterRoutes(RouteCollection routes) { routes

SQL Switch/Case in 'where' clause

不羁的心 提交于 2019-12-17 02:58:20
问题 I tried searching around, but I couldn't find anything that would help me out. I'm trying to do this in SQL: declare @locationType varchar(50); declare @locationID int; SELECT column1, column2 FROM viewWhatever WHERE CASE @locationType WHEN 'location' THEN account_location = @locationID WHEN 'area' THEN xxx_location_area = @locationID WHEN 'division' THEN xxx_location_division = @locationID I know that I shouldn't have to put '= @locationID' at the end of each one, but I can't get the syntax

Easier way than using a switch case to change color

穿精又带淫゛_ 提交于 2019-12-14 03:56:45
问题 On my website, I use a switch case to give a color to the navigation bar's active link. I first declared an array $case with all the possible links in the navigation bar. Then, I check to see if it's a function clicked on one of the pages (if the query string isn't empty) and if it was put into the $case array (to keep from changing color when other links inside other pages are clicked.) If true, $current will get a value like docs_zamo or akuut_wgakuut --> FILENAME_QUERY. I only want to

Case statements with alias

无人久伴 提交于 2019-12-14 02:56:56
问题 I need to create a table with a user id and an assigned value. I have these three select statements: select sales_person_id from promotions where sales > 30000 and city = ‘Georgia’ select sales_person_id from promotions where sales > 50000 and city = ‘Atlanta’ select sales_person_id from promotions where sales > 25000 and city = ‘Tampa’ Basically I would need it to show if select statement one, the table would contain user_id and value = 10 if select statement two user_id and value = 5 if

Android Multiple Intents - One Form

江枫思渺然 提交于 2019-12-13 23:30:25
问题 Good afternoon, I am trying to create a basic menu in my andorid application which contains 5 buttons each bringing you to another form. I am trying to create the java to carry out this action but appear to be running into the following error with each of my buttons "EXAMPLE cannot be resolved as a variable" Please help me in a solution to my code or if there is a simpler way to allow me to execute this menu with 5 buttons each going to a different form <RelativeLayout xmlns:android="http:/

CASE statement and how to use values from it

自古美人都是妖i 提交于 2019-12-13 21:37:57
问题 I have a query select p.ID as order_id, p.post_date, i.order_item_id, max( CASE WHEN im.meta_key = '_product_id' and i.order_item_id = im.order_item_id THEN im.meta_value END ) as product_id, max( CASE WHEN im.meta_key = '_qty' and i.order_item_id = im.order_item_id THEN im.meta_value END ) as qty, max( CASE WHEN prm.meta_key = '_sku' and im.meta_value = prm.post_id THEN prm.meta_value END ) as sku, max( CASE WHEN prm.meta_key = '_regular_price' and im.meta_value = prm.post_id THEN prm.meta

Replacing NULL from results of CASE query

佐手、 提交于 2019-12-13 21:31:42
问题 I have the following code which generates data similar to mine. The posting here (PivotWithoutAggregateFunction) suggested that using a CASE statement rather than PIVOT was better for non-numeric values. Which if this is not true then I guess now is the time to fix it ! DECLARE @QA1 TABLE (SID varchar(7), FormID varchar(max), DateExam date, Present varchar(3)) INSERT INTO @QA1 VALUES(1, 'Form1', '20110101', 'Yes') INSERT INTO @QA1 VALUES(2, 'Form1', '20110201', 'Yes') INSERT INTO @QA1 VALUES

Continuous input to switch case until i press exit c#

泪湿孤枕 提交于 2019-12-13 20:13:32
问题 I am trying to create a program where the application should never exit until I press option '6'. Below is my sample program: Right now, if I press any option, it executes the corresponding method and console window closes (exits the application) after it is done executing. I want the console to wait for the next option to be entered. Console.WriteLine(@"Select one of the following option: 1-Write Apps 2-Write Drivers 3-Write OS 4-Write Packages 5-All the above 6-Exit"); string strReadKey =

SQL CASE WHEN …AND

夙愿已清 提交于 2019-12-13 19:23:53
问题 Is there a way to write a SQL query like this: CASE WHEN DATEPART(yy,@year_end) = 2013 AND DATEPART(mm,@year_end) = 3 THEN @AdjStartYear = '2012/07/01' AND @AdjEndYear = '2012/12/31' Basically, I want 2 things to happen after the CASE statement is evaluated. Thanks 回答1: No, you have to make 2 case statements select @AdjStartYear = CASE WHEN DATEPART(yy,@year_end) = 2013 AND DATEPART(mm,@year_end) = 3 THEN '2012/07/01' END, @AdjEndYear = CASE WHEN DATEPART(yy,@year_end) = 2013 AND DATEPART(mm,