case

MySQL View check if data is NULL

I need to put a Case in the Select to check if the Data I'm adding to my view is NULL, in which case I want it to just enter a zero, or not. ...

Is there any good open-source software to write test cases?

I'd like to have historical memory of the test cases I usually do to verify a software suite, and the company in which I work now uses word or excel docs for this task, but I'd like something more focused on the type of task. What do you use? Is there any open-source software to fill with test cases? Thanks ...

Transact SQL CASE over a variable length input_expression

I have to produce an ad hock report on the number of transactions made with different credit card types. For the purposes of the report it is fine to assume that all credit cards that start with a 4 are VISA cards and that those that start with a 5 are MasterCard. This query works well for the above distinctions: select card_type = ...

Handling empty set in MySQL CASE statement

MySQL server version 5.0.45. Consider the following: ( SELECT CASE WHEN t.group_id = 12 THEN 'yes' ELSE 'no' END FROM sample_table t WHERE t.user_id = 2 AND t.group_id = 12 ) as foo This subquery of a larger statement works as I'd expect, yielding a 'yes' or 'no' string value most of the time. It's not ideal...

Case statement with logic operators (< > =, etc) in Pascal.

Hello there! I'm having trouble making this work. Apparently, i can't use > or < in the case sentence, is there a workaround for this? Thanks! case num of 0: begin cont_0 := cont_0 + 1; end; > 0: begin cont_pos := cont_pos + 1; sum_pos := sum_pos + num; end; ...

How can I add an additional condition to this query (using CASE) ?

Here's my query so far: SELECT posts.title , SUM(CASE comments.status WHEN 'approved' THEN 1 END) AS commentsCount FROM posts INNER JOIN comments ON comments.postID = posts.id WHERE posts.status = ? GROUP BY posts.title ORDER BY commentsCount DESC ...

Best way to count this Data...

In short I have 2 tables: USERS: ------------------------ UserID | Name ------------------------ 0 a 1 b 2 c CALLS: ------------------------ ToUser | Result ------------------------ 0 ANSWERED 1 ENGAGED 1 ANSWERED 0 ANSWERED ect ect (i use a numerical referance for result in reality) I have over ...

What are the best free CASE tools for PHP?

What are your favorite free CASE/UML/Code generation/diagramming tools that you use with PHP? There are various commercial products that support code generation in PHP language, are there any free CASE tools? What would you recommend? ...

Nested case in bash script

I have written the following function in a bash script but it is not working. Am I missing something obvious? main_menu() { dialog \ --title "Sim Gateway Infomation Utility" \ --menu "What do you want to do?" 12 60 5 \ Summary "View overall summary" \ Details "View details of a sim bank" \ Modify "Modify used minutes...

Hibernate hql problem using case keyword

Hello! I really need help regarding this one. Here is the code snippet: hSql=" select case when min(start_day_plan) is not NULL then min(start_day_plan) else to_date((min(insertDate)) - cast('1 month' as interval),'yyyy-MM-dd' ) end from Project" getHibernateTemplate().find(hSql); But this generates the error below: java...

scala case classes questions

Hi, I have two questions regarding the '::' case class. :: can be used as case head :: tail => ... How does it work? Meaning, what is exactly the flow that Scala uses to match a List instance with the :: case class? Given that I have a class MyClass, with operator op, can I create a case class named op that I can use as: case foo o...

SQL qn:- Case expression

Hi, I have data in table a that i want to quench and create into another table b. Wondering how to do this. I was thinking of doing nested CASE expressions. But is this do-able? For eg:- Table a:- S En Eg -0.2 7888 99 90 9000 788 100 999 888 I want to create another table b, that does this:- select...

SQL query with count and case statement

i need to find how many people have filed (fil_dt) their tax return within 60 days, withing 120 days, within 180 days, over 180 days of their filing period end date (fpe) for 3 different years (2006, 2007, 2008) the statement below will give me ALL years i need a count for each year and for each possibility.. anyway i can do this withou...

T-SQL Where Clause Case Statement Optimization (optional parameters to StoredProc)

I've been battling this one for a while now. I have a stored proc that takes in 3 parameters that are used to filter. If a specific value is passed in, I want to filter on that. If -1 is passed in, give me all. I've tried it the following two ways: First way: SELECT field1, field2...etc FROM my_view WHERE parm1 = CASE WHEN @PARM...

LINQ to SQL lambda exp. OrderBy, Case When

Hi guys! Going to need your help on this one. I'm trying to OrderBy first reply datetime if present. If it's empty/null, it must order by topic datetime. I've ended up with the following expression, but it just doesn't seem to work :( return db.Topics .Where(t => t.ForumID == id) .OrderBy( t => t.Replies .OrderBy(r => r.AddDat...

How much statement can be made conditional in MySQL?

Hi, the MySQL manual says that a CASE statement (the WHEN part) can contain a statement_list. How much statement is that to be exact? I need to perform a pretty big query which I would like to parametrize. However this also implies that I need to change tables that are being joined. I've read that this cannot be done using CASE statemen...

Why are parenscript functions changed to all lowercase?

When using parenscript if I execute (parenscript:ps (slot-value ($ "#mytextarea") 'selectionStart)) It produces the javascript $('#mytextarea').selectionstart; Note that selectionStart is now selectionstart. It lost the uppercase S on the Start! How do I keep that uppercase S around? ...

MySQL CASE "Else Case When" is executing when the precondition is true - what am I missing?

I have a table that, due to the third party system we are using, sometimes has duplicate data. Since the model uses an EAV method there's no way to filter this the "right" way, so I am aggregating the data into a View - I know this is a data collection problem but it's easier for me to fix it on the display end than go through this syst...

I want to have a SQL computed column according to rules

Hi all! I want to be able to store a decimal value in one column, and in the other column to store an int that represents the option (will explain): should be base -% should be base -absolute should be base +% should be base +absolute 1 & 2 is a discount 3 & 4 is an upcharge 1 & 3 reduces/raises the amount by percentage (i.e. amount *...

SQL Server Where Clause Case Statement?

I have a Where Clause that checks the existence of rows in a subquery, but I only want to execute that check if a bit is set to 1. So for example: Select * from Listing l Where l.IsDeleted=1 AND CASE WHEN @MustHasPicture = 1 THEN ( EXISTS ( SELECT NULL AS [EMPTY] FROM [dbo].[ListingPictures] AS [lp] INNER JOIN...