spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

CASE statement plus modulo (%)


try this:

DECLARE @Zmienna AS INT
SET @Zmienna = 0

WHILE @Zmienna < 999
BEGIN
    PRINT CAST(@Zmienna as varchar) +
        CASE
            when (@Zmienna%3=0 AND @Zmienna%5=0) 
THEN ' hip hop'
            WHEN @Zmienna%3=0 THEN ' hip'
            WHEN @Zmienna%5=0 THEN ' hop'

        END 
    SET @Zmienna = @Zmienna + 1
END

Categories : SQL

Related to : CASE statement plus modulo (%)
Large Integer Arithmetic - how to implement modulo?
Method 1 I came up with this method; it's not necessarily efficient, but it works. Notice that you can use the length of the input (in digits) to compute its logarithm. You can use this to perform division, and therefore modulus. Specifically, first notice that 849465603662254214335539562 / (578907659710377778063722 * 1000) = 1.4... Therefore 849465603662254214335539562 - 578907659710377778

Categories : Java
How to use sybase in built function with prepared statement insert statement?
Try using below code : insert into dbase..tempTable(Column1, Column2, Column3) select isnull(?,'X'),isnull(?,'Y'),cast(? as numeric(31,11)) pst.setString(1,str); pst.setString(2,str2); pst.setString(3,100); Hope this helps :)

Categories : Java
Syntax for MySQL SELECT statement with a subquery within the IF statement
You need a something before the subselect: SELECT * FROM Products WHERE Color = 'Black' AND IF (Item = 'Dresses' ?? (SELECT * FROM Products WHERE Price < '$300'), 1, 0) = 1 --------------------------^ I am not quite sure what, because there are many other problems, such as: Using * where a scalar subquery is expected. Using '$300' to presumably compare against a number. (Or worse, st

Categories : Mysql
jsp command <%=%> being ignored when it is used in a Javascript statement, inside a taglib tag statement?
Here's a bit of a cheat solution, you dont need the JSP tag in that JS call. In fact, it's tidier this way <jam:text onmousedown="movePage(this.id);" id="<%=targetPage%>"><%=targetPage%></jam:text>

Categories : Java
Enquiry Form in MYSQL. IF statement within a mysql select statement, if field is empty, left join to get the replacement value
Use ISNULL function. SELECT ISNULL((SELECT name FROM a_table WHERE user_id = @usr), (SELECT name FROM i_user WHERE user_id = @usr)) AS name, ISNULL((SELECT [address] FROM a_table WHERE user_id = @usr), (SELECT [address] FROM i_user WHERE user_id = @usr)) AS a_address FROM DUAL Or use a left outer join: SELECT ISNULL(t1.name, t2.name) AS name, ISNULL(t1.address, t2.a

Categories : Mysql
Recently Add
SQL to COUNT items associated with individuals
sqlite in syntax, by column
Get DISTINCT Sum of Total by WorkID with LEFT JOINs
Create a trigger dealing with two tables
SQL: Combinations by Type
T-SQL Procedure split and join on sub columns
GROUP BY in Informix (11.5)
Returning duplicates based on one value in SQL
Joins over non-key attributes
MS-Access SELECT TOP N subquery SQL
Rails PG::UndefinedTable: ERROR: missing FROM-clause entry for table
Case-insensitive primary key of type nvarchar where ß != ss
Get min and max value from a multiple rows events
JPA/Hibernate: on delete set null
How do i structure a query where I am INSERTing into a new table and need to increment a column every time?
sql query to groupby with a deduplicated column
Oracle left-outer-join syntax shorthand notation (+) available in HQL?
Selecting numbers into array and then looping over them
Update query to fix incorrect references between two tables
Merging query records into one
How to select duplicate columns data from table
Confused syntax in Where clause
SQL Server 2005 GROUP BY and COUNT query for each month
error in sql query result
Can IIS and SQL run on the same Azure Virtual Machine?
SQL query to find all names where same user_id count > 3
SQL return a default value if a row is not found [PostgreSQL]
Schema Design for Invoices and Transaction - "mystery" relation
sql create table same primary & foreign key
Adding FK constraint WITH CHECK (SQL Server)
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.