Mahonek
asked on
Converting Access Query To SQL Script
Hello programmers. I need a little help rewriting a query to SQL script. The following Script is giving me the following errors. Can someone help me identify a fix. Thanks.
SCRIPT:
SELECT DISTINCT
'999998' AS exp1, oas_testit2.el1,
Sum(oas_testit2.Actual) AS SumOfActual,
Sum(oas_testit2.Budget) AS SumOfBudget,
Sum(oas_testit2.Prior_Act) AS SumOfPrior_Act,
Sum(oas_testit2.Actual_YTD ) AS SumOfActual_YTD,
Sum(oas_testit2.Budget_YTD ) AS SumOfBudget_YTD,
Sum(oas_testit2.Prior_YTD) AS SumOfPrior_YTD, oas_testit2.yr, oas_testit2.period, oas_testit2.base_grp
FROM oas_testit2
WHERE (((oas_testit2.el2)<>'9999 99' And (oas_testit2.el2)<>'299999 ' And (oas_testit2.el2)<>'399999 ' And (oas_testit2.el2)<>'003035 '
And (oas_testit2.el2)<>'999994 ' And (oas_testit2.el2)<>'999995 ' And (oas_testit2.el2)<>'999996 ' And (oas_testit2.el2)<>'999997 '
And (oas_testit2.el2)<>'990100 ' And (oas_testit2.el2)<>'990200 ' And (oas_testit2.el2)<>'990300 ' And (oas_testit2.el2)<>'990400 '
And (oas_testit2.el2)<>'990500 ' And (oas_testit2.el2)<>'990600 ' And (oas_testit2.el2)<>'990700 ' And (oas_testit2.el2)<>'990800 '))
GROUP BY '999998', oas_testit2.el1, oas_testit2.yr, oas_testit2.period, oas_testit2.base_grp
HAVING (((oas_testit2.el1)<>'4494 9' And (oas_testit2.el1)<>'44959' And (oas_testit2.el1)<>'44969' And (oas_testit2.el1)<>'44979'
And (oas_testit2.el1)<>'44989' And (oas_testit2.el1)<>'44999' And (oas_testit2.el1)<>'49999' And (oas_testit2.el1)<>'44919' ))
ERRORS:
Server: Msg 164, Level 15, State 1, Line 1
GROUP BY expressions must refer to column names that appear in the select list.
Server: Msg 170, Level 15, State 1, Line 15
Line 15: Incorrect syntax near 'oas_testit2'.
SCRIPT:
SELECT DISTINCT
'999998' AS exp1, oas_testit2.el1,
Sum(oas_testit2.Actual) AS SumOfActual,
Sum(oas_testit2.Budget) AS SumOfBudget,
Sum(oas_testit2.Prior_Act)
Sum(oas_testit2.Actual_YTD
Sum(oas_testit2.Budget_YTD
Sum(oas_testit2.Prior_YTD)
FROM oas_testit2
WHERE (((oas_testit2.el2)<>'9999
And (oas_testit2.el2)<>'999994
And (oas_testit2.el2)<>'990100
And (oas_testit2.el2)<>'990500
GROUP BY '999998', oas_testit2.el1, oas_testit2.yr, oas_testit2.period, oas_testit2.base_grp
HAVING (((oas_testit2.el1)<>'4494
And (oas_testit2.el1)<>'44989'
ERRORS:
Server: Msg 164, Level 15, State 1, Line 1
GROUP BY expressions must refer to column names that appear in the select list.
Server: Msg 170, Level 15, State 1, Line 15
Line 15: Incorrect syntax near 'oas_testit2'.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What does this yield?
Open in new window