Jump to content
TNG Community

Marriage report by day of the week


Recommended Posts

I have a report for marriages by day of the week.

 

SELECT 
    CASE DAYOFWEEK(marrdatetr) 
         WHEN 1 THEN 'Sunday'
        WHEN 2 THEN 'Monday'
        WHEN 3 THEN 'Tuesday'
        WHEN 4 THEN 'Wednesday'
        WHEN 5 THEN 'Thursday'
        WHEN 6 THEN 'Friday'
        WHEN 7 THEN 'Saturday'
    END AS Marriage_Day,
    COUNT(*) AS Number_of_Marriages
FROM tng_families
WHERE marrdatetr != '0000-00-00'
AND marrdatetr IS NOT NULL
GROUP BY DAYOFWEEK(marrdatetr)
ORDER BY DAYOFWEEK(marrdatetr);

 

This is the result. Can't figure out why the numbering if off.

tng marriage report.jpg

Link to comment
Philip Roy

I suggest you paste it into ChatGPT and ask. I just did and got a lengthy response with possible causes. Too long to list here, but some useful ideas

IMPORTANT - Do not paste actual TNG code into AI…it’s a breach of the copyright for TNG. As this is generic SQL  it’s ok to paste it in.

Link to comment
ajnsmits

Katryne is right.
I've updated the query, and in my records, there are 9 entries that only have a year listed for the marriage.

 

SELECT 
	CASE DAYOFWEEK(marrdatetr) 
    	WHEN 1 THEN 'Sunday' 
    	WHEN 2 THEN 'Monday' 
    	WHEN 3 THEN 'Tuesday' 
    	WHEN 4 THEN 'Wednesday' 
    	WHEN 5 THEN 'Thursday' 
    	WHEN 6 THEN 'Friday' 
    	WHEN 7 THEN 'Saturday' 
    	ELSE 'unkown'
	END AS Marriage_Day,
COUNT(*) AS Number_of_Marriages
FROM tng_families
WHERE marrdatetr != '0000-00-00' 
AND marrdatetr IS NOT NULL
GROUP BY DAYOFWEEK(marrdatetr)
ORDER BY CASE WHEN Marriage_Day = 'unkown' THEN 1 ELSE 0 END,
MIN(DAYOFWEEK(`marrdatetr`)) ASC; 

André

Schermafbeelding 2026-06-30 113813.jpg

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...