Solved

Could you break this down for me?

Posted on 2016-10-03
5
54 Views
Last Modified: 2016-10-03
Here's the line of code I want to understand:

coalesce(max(cast(statement.exportdate as date)),'1950-01-01')

One piece at a time, here we go:

Coalesce: returns the first value that isn't NULL.
Max: Here, I'm getting the most recent date in the recordset
Cast: converts whatever data you're looking at to a specific data type. In this instance, it's a timestamp and I'm converting it to a date

What's "1950-01-012?"
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:brucegust
ID: 41826541
Last part: 1950-01-01. Uncooperative fingers...
0
 
LVL 50

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41826548
What's "1950-01-01?"
Means that if returned a NULL value it will be replaced by 1950-01-01.
0
 

Author Closing Comment

by:brucegust
ID: 41826555
Perfect!

Thanks!
0
 
LVL 50

Expert Comment

by:Vitor Montalvão
ID: 41826556
Anyway that test is not necessary since MAX() never returns NULL, so you can replace it with max(cast(statement.exportdate as date)).
0
 

Author Comment

by:brucegust
ID: 41826671
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question