![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How would I right a case statement like this in Access? SELECT COUNT(CASE WHEN Location = N'Inner Mass Spec.' AND EpaName = N'leak1' THEN MFG_SN END) AS InnerCount, COUNT(DISTINCT CASE WHEN Location = N'Final Assembly (Box)' THEN MFG_SN END) AS FinalAssembly FROM ChartMES.dbo.RecourceActualEPA_Report WHERE Timestamp > '20100422050000' AND Timestamp < '20100422143000'; |
#3
| |||
| |||
|
|
How would I right a case statement like this in Access? SELECT COUNT(CASE WHEN Location = N'Inner Mass Spec.' AND EpaName = N'leak1' THEN MFG_SN END) AS InnerCount, COUNT(DISTINCT CASE WHEN Location = N'Final Assembly (Box)' THEN MFG_SN END) AS FinalAssembly FROM ChartMES.dbo.RecourceActualEPA_Report WHERE Timestamp > '20100422050000' AND Timestamp < '20100422143000'; |
#4
| |||
| |||
|
|
mcolson <mcolson1... (AT) gmail (DOT) com> wrote innews:6d6ffd6f-4037-4b13-abbc-5d82277113a6 (AT) c36g2000yqm (DOT) googlegroups.co m: How would I right a case statement like this in Access? SELECT COUNT(CASE WHEN Location = N'Inner Mass Spec.' AND EpaName = N'leak1' THEN MFG_SN END) AS InnerCount, * * * * COUNT(DISTINCT CASE WHEN Location = N'Final Assembly * * * * (Box)' THEN MFG_SN END) AS FinalAssembly FROM ChartMES.dbo.RecourceActualEPA_Report WHERE Timestamp > '20100422050000' * *AND Timestamp < '20100422143000'; Something like that generally indicates to me that you are storing data in your SQL statement. The choices in the CASE statement should be stored in a data table. If you're not willing (or are unable) to do it properly, you might want to look at the Switch() and Choose() functions in VBA. -- David W. Fenton * * * * * * * * *http://www.dfenton.com/ usenet at dfenton dot com * *http://www.dfenton.com/DFA/ |
#5
| |||
| |||
|
|
On Apr 27, 6:09*pm, "David W. Fenton" <XXXuse... (AT) dfenton (DOT) com.invalid wrote: mcolson <mcolson1... (AT) gmail (DOT) com> wrote innews:6d6ffd6f-4037-4b13-abbc-5d82277113a6 (AT) c36g2000yqm (DOT) googlegroups.co m: How would I right a case statement like this in Access? SELECT COUNT(CASE WHEN Location = N'Inner Mass Spec.' AND EpaName = N'leak1' THEN MFG_SN END) AS InnerCount, * * * * COUNT(DISTINCT CASE WHEN Location = N'Final Assembly * * * * (Box)' THEN MFG_SN END) AS FinalAssembly FROM ChartMES.dbo.RecourceActualEPA_Report WHERE Timestamp > '20100422050000' * *AND Timestamp < '20100422143000'; Something like that generally indicates to me that you are storing data in your SQL statement. The choices in the CASE statement should be stored in a data table. If you're not willing (or are unable) to do it properly, you might want to look at the Switch() and Choose() functions in VBA. -- David W. Fenton * * * * * * * * *http://www.dfenton.com/ usenet at dfenton dot com * *http://www.dfenton.com/DFA/ I'm not sure what you mean storing data in my SQL statement. *I'm looking to predefine a query that I can call. *The timestamps will end up being parameters that are passed to the query.- Hide quoted text - - Show quoted text - |
#6
| |||
| |||
|
|
On Apr 27, 6:09*pm, "David W. Fenton" XXXuse... (AT) dfenton (DOT) com.invalid> wrote: mcolson <mcolson1... (AT) gmail (DOT) com> wrote innews:6d6ffd6f-4037-4b13-abbc-5d82 277113a6 (AT) c36g2000yqm (DOT) googlegroups.co m: How would I right a case statement like this in Access? SELECT COUNT(CASE WHEN Location = N'Inner Mass Spec.' AND EpaName = N'leak1' THEN MFG_SN END) AS InnerCount, * * * * COUNT(DISTINCT CASE WHEN Location = N'Final Assembly * * * * (Box)' THEN MFG_SN END) AS FinalAssembly FROM ChartMES.dbo.RecourceActualEPA_Report WHERE Timestamp > '20100422050000' * *AND Timestamp < '20100422143000'; Something like that generally indicates to me that you are storing data in your SQL statement. The choices in the CASE statement should be stored in a data table. If you're not willing (or are unable) to do it properly, you might want to look at the Switch() and Choose() functions in VBA. I'm not sure what you mean storing data in my SQL statement. I'm looking to predefine a query that I can call. The timestamps will end up being parameters that are passed to the query. |
![]() |
| Thread Tools | |
| Display Modes | |
| |