Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Some reason this isn't coming to me today. I usually can get by this issue but maybe it's just lack of sleep.I have the followingSELECT [User ID],COUNT ([Work Order Number]) AS [Work Order Count]FROM vwWORDMPF_descWHERE [W/O Type]='TC' AND [User ID]= 'User1' AND [Date Entered]='6/15/2009'GROUP BY [User ID]UNION SELECT [User ID],COUNT ([Work Order Number]) AS [Work Order Count]FROM vwWOMHIPF_descWHERE [W/O Type]='TC' AND [User ID]= 'User1' AND [Date Entered]='6/15/2009'GROUP BY [User ID]I get the following backUser ID 1 from file 1 COUNT = 1User ID 1 from file 2 COUNT = 5This is the basis to the query. I have several columns that I'm either counting or suming but I only have 3 Columns that I need to group bySite , User and Date Entered
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-06-20 : 01:45:24
seems like this is what you're looking at:-
SELECT [User ID],COUNT ([Work Order Number]) AS [Work Order Count]FROM(SELECT [User ID],[Work Order Number]FROM vwWORDMPF_descWHERE [W/O Type]='TC' AND [User ID]= 'User1' AND [Date Entered]='6/15/2009'GROUP BY [User ID]UNION SELECT [User ID],[Work Order Number]FROM vwWOMHIPF_descWHERE [W/O Type]='TC' AND [User ID]= 'User1' AND [Date Entered]='6/15/2009')tGROUP BY [User ID]
ZMike
Posting Yak Master
110 Posts
Posted - 2009-06-20 : 09:08:33
visakh16,Thanks ! I'll give it a go later today. Do you happen to know if the same logic also works in Sequel Viewpoint ? I use both at work and at the current time I can't put the end results in SQL Server (we dont have the table from our AS400 Loaded into it yet.