sql how to use case?

Sven van den Boogaart

Hello i have 2 tables 1 with btwvalues and 1 with orders

I am trying to select the final rate (

    if extrahours =1 then finalhourscost = extrahoursrate 
    else finalhourcost = hoursrate)

i have made an example

http://www.sqlfiddle.com/#!2/dd8d9/17

So what i want is create a row finalhourscost depending on both tables. finalhourcost is not an existing row.

What have i done wrong , as you see it returns 1 instead of 40

Mureinik
SELECT extrahours, 
       extrahourrate,
       hourrate,
       CASE extrahours WHEN 0 THEN extrahourrate ELSE hourrate END AS finalrate
FROM bill JOIN cost ON bill.costid = cost.id

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to use SQL join with case

From Dev

How to use the SQL CASE Statement in between conditions

From Dev

How to use struct in this case

From Dev

How to use CASE in Where statment Oracle SQL?

From Dev

How to use a functional in this case?

From Dev

How to use Case in SQL?

From Dev

How use case with findwindow

From Dev

How to use case statement inside an SQL select Query

From Dev

How to use mocking in this case?

From Dev

How to use decltype in this case

From Dev

Use case statement in SQL

From Dev

how to use > = condition in sql case statement?

From Dev

how to use count, case and Distinct together in sql server

From Dev

How to use case here

From Dev

How to use SELECT with GROUP BY and HAVING in a specific SQL case

From Dev

How to use lastInsertId in this case?

From Dev

How to use case statement inside where clause of sql 2000

From Dev

Where and how to use CASE WHEN SQL multiple sub queries

From Dev

How to use the SQL CASE Statement in between conditions

From Dev

How use Greater Than 0 (>0) within Case in Sql Server?

From Dev

How to use case in sql query

From Dev

How to use Not Equal with CASE statement in SQL query

From Dev

how to use count, case and Distinct together in sql server

From Dev

How to use CASE statement in SQL Server

From Dev

How to use NOT EXISTS in SQL Server in my case?

From Dev

How to properly use SQL CASE statement

From Dev

How to use SQL to concatenate two rows with grouping and CASE

From Dev

How to use PreparedStatement in SQL having CASE statement

From Dev

SQL query to get average as below case or how to use hibernate criteria