SavageLearning / Machete

A web application for managing a day laborer referral organization. Built using .NET Core MVC, Entity Framework Core, jQuery, Datatables (datatables.net).
GNU General Public License v3.0
16 stars 17 forks source link

Unnamed columns won't run, throw exception #680

Open esteban-gs opened 2 years ago

esteban-gs commented 2 years ago

WHAT

queries without a column name won't run:

DECLARE @beginDate datetime = '2020-01-01';  
DECLARE @endDate datetime = GETDATE();   
with
signins (dwccardnum, signincount)
    as
    (
        select wsi.dwccardnum, count(*) as [signincount]
        from WorkerSignins wsi

        Where wsi.dateforsignin >= @begindate
            and wsi.dateforsignin < @enddate
        group by wsi.dwccardnum
    )
select
    si.dwccardnum as [cardnum],
    si.signincount as [sign ins],
    FORMAT( w.dateOfBirth, 'd', 'en-US' ), -- unnamed column 
    DATEDIFF(year, w.dateOfBirth,  GETDATE()) as [age],
    p.fullName,
    p.nickname,
    p.phone, 
    p.cellphone,
    p.email,
    p.facebook
from
    Workers w
    join Persons p on p.ID = w.ID
    join signins si on si.dwccardnum = w.dwccardnum 
WHERE w.dateOfBirth <= DATEADD(month, -589, GETDATE())
ORDER BY DATEDIFF(year, w.dateOfBirth,  GETDATE())

WHERE

Report editor