MySQL - Query Questions

Hi Guys

I'm using the CASE function in the query below.

 SELECT
  from_unixtime(b.`date_create`) AS 'Booking  Date'
  ,from_unixtime(b.`timeslot`)   AS 'Allocated Date & Time Slot'
  ,b.`minutes`                   AS 'Minutes'
  ,b.`voucher_title`             AS 'Product Name'
  ,b.`customer_name`             AS 'Customer Name'
  ,from_unixtime(c.`birthdate`)  AS 'Customer DOB'
  ,c.address                               AS 'Address'
  ,c.city                                   AS 'City'
  ,c.postal_code                         AS 'Post Code'
  ,c.email                                 AS 'Customer Email'
  ,b.`customer_num`              AS 'Guest Number'
  ,b.`invoice_id`                AS 'Invoice Number'
  ,i.total_ht                                AS 'Gross'
  ,i.total_tva                             AS 'Tax'
  ,i.paid_ttc                               AS 'Total Received'
  ,i.origin                                     AS 'Bookig Method'
  ,(CASE WHEN b.checkin <- 1 THEN "Un-Finalized"
         WHEN b.checkin > 1  THEN "Finalized"
    END)                         AS Finalized
 
  FROM `booking` b
  JOIN customers c ON c.customer_num = b.customer_num
  JOIN invoices  i ON i.id                   = b.invoice_id

The table "checkin" has either a 0 or a 10 digits, such as 1515663909. What I'm trying to achieve is below

IF b.checkin < 0 THEN Un-Finalized
IF b.checkin > 0 THEN Finalized

I'm able to run the query above but I don't feel the CASE function works, any ideas?

Thanks All!
Stevie ZakhourAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
IF b.checkin < 0 THEN Un-Finalized

you should have condition of IF b.checkin = 0 THEN Un-Finalized since your value can't go below 0.

so just try:

(CASE WHEN b.checkin =0 THEN "Un-Finalized" else "Finalized"  END) AS Finalized

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulEE Topic AdvisorCommented:
no points pl:

or you could reverse the bove

(CASE WHEN b.checkin > 0 THEN "Finalized" else "Un-Finalized"  END) AS Finalized

Open in new window

0
Stevie ZakhourAuthor Commented:
Awesome, that worked! Thanks Ryan!!!
0
Stevie ZakhourAuthor Commented:
Thanks All for Helping!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.