Hi there
I'm somewhat new to complex SQL and I'm trying to use a grouping on SIN and want to sort on edit_Time, but need to have Sin LAST PROGRAM PAY_AMT in the select statement for the report
EDIT_Time YR MNTH SIN LAST PROGRAM Pay
2020-09-21 10:56:30.713 2023 01-JUL ***011079 BEAUDIN BCECTB 99.00
2020-09-21 10:17:29.690 2051 01-JUL ***011079 BEAUDIN BCECTB 104.01
2020-09-21 10:04:57.733 2051 01-JUL ***011079 BEAUDIN BCECTB 104.00
2020-09-18 21:48:51.963 2051 01-JUL ***918469 DAN BCECTB
2020-09-18 15:44:40.560 2051 01-JUL ***011079 BEAUDIN BCECTB 66.00
2020-09-18 15:08:28.763 2023 01-JUL ***011079 BEAUDIN BCECTB 55.00
2020-09-04 09:59:23.953 2020 04-OCT ***847715 RICHARD BCECTB
2020-09-04 09:59:12.073 2020 04-OCT ***847715 RICHARD BCECTB
2020-08-19 14:59:44.037 2020 01-JUL ***183435 SAWDEN BCECTB 1.00
2020-08-19 14:52:06.523 2020 01-JUL ***183435 SAWDEN BCECTB 2.05
2020-08-19 12:58:53.113 2020 01-JUL ***847715 RICHARD BCECTB
2020-08-19 08:55:43.073 2020 01-JUL ***183435 SAWDEN BCECTB 99.00
2020-08-19 08:38:33.067 2020 01-JUL ***183435 SAWDEN BCECTB 99.00
2020-08-18 15:35:45.220 2020 01-JUL ***847715 RICHARD BCECTB
2020-08-18 13:24:30.933 2020 01-JUL ***847715 RICHARD BCECTB
2020-08-18 13:10:28.563 2020 01-JUL ***847715 RICHARD BCECTB
I have
Select EDIT_Time ,YR, MNTH, SIN , LAST, PROGRAM, Pay
from EDITED_PAYMENT_View
group by SIN, EDIT_Time ,YR, MNTH, LAST, PROGRAM, Pay
order by [EDIT_Time] desc
but that doesn't properly group the SIN's and sort EDIT_Time
this groups and sorts properly: but I need the rest of the fields in the select
SELECT TOP (100) PERCENT SIN, EDIT_Time
FROM EDITED_PAYMENT_View
GROUP BY SIN, EDIT_Time
Any help would be great
Thx