I'm working this query and just getting an syntax error.
It does work perfect with SQL 2000 just haven't been able to make it work on Access 2003.
Any ideas?
SELECT ( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) AS ROW_A,
RTRIM( Table2.LNAME ) + ',' + Table2.FNAME AS NAME_A,
Table2.GRADE AS GRADE_A,
( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) + 4 AS ROW_B,
RTRIM( Values_B.LNAME ) + ',' + Values_B.FNAME AS NAME_B,
Values_B.GRADE AS GRADE_B
FROM table2
LEFT JOIN ( SELECT FNAME, LNAME, GRADE,
( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) AS Row_number
FROM Table2
WHERE ( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) > 4
) AS Values_B ON Values_B.Row_number = ( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) + 4
WHERE ( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) < 5
It does work perfect with SQL 2000 just haven't been able to make it work on Access 2003.
Any ideas?
SELECT ( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) AS ROW_A,
RTRIM( Table2.LNAME ) + ',' + Table2.FNAME AS NAME_A,
Table2.GRADE AS GRADE_A,
( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) + 4 AS ROW_B,
RTRIM( Values_B.LNAME ) + ',' + Values_B.FNAME AS NAME_B,
Values_B.GRADE AS GRADE_B
FROM table2
LEFT JOIN ( SELECT FNAME, LNAME, GRADE,
( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) AS Row_number
FROM Table2
WHERE ( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) > 4
) AS Values_B ON Values_B.Row_number = ( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) + 4
WHERE ( SELECT COUNT(*) FROM Table2 AS cnt WHERE cnt.LNAME <= Table2.LNAME ) < 5