Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. tonydismukes

    Using GROUP BY with UNION

    dnoeth - thanks, that works too. I had tried that, but I didn't know the syntax required providing a name for the derived table, so it wasn't working. I had tried: select partner, sum(totalData) from (your union-query here ) group by partner which doesn't work. I neeed a better SQL...
  2. tonydismukes

    Using GROUP BY with UNION

    Zathras, as it so happens, I'm using SQL Server. Let me check ... IT WORKS! Thank you! I don't think I would have gotten that one very quickly on my own.
  3. tonydismukes

    Using GROUP BY with UNION

    I have a table holding information on data sent: CREATE TABLE DataSent (SENDERKEY int, RECEIVERKEY int, SIZE int, PROCESSDATE datetime, ... other irrelevant fields ...) I need to generate a report showing the total quantity of data sent or received by a particular account, within a date...
  4. tonydismukes

    Applying HAVING (or equivalent) to subquery results

    That does it PHV, thanks!
  5. tonydismukes

    Applying HAVING (or equivalent) to subquery results

    Um, swampBoogie, I'm not sure how that will work. Even if I put the where clause in the right place (before the group by) and change it to "Jan > 0 and Feb > 0" (which is what I want), SQL Server still gives me the "Invalid column name" error. Anyway, I'm pretty certain I need something that...
  6. tonydismukes

    Applying HAVING (or equivalent) to subquery results

    I have a dynamically built query that returns monthly sales totals grouped by product sold, location and salesman. If the customer asked for results from 1/1/2006 to 2/15/2006, the query would look something like this: select n.location,d.salesman_num, d.item_description, (select...
  7. tonydismukes

    Server: Msg 8624, Level 16, State 21, Line 1 Internal SQL Server error

    Update: I tried just bypassing the view entirely and running the query against the underlying tables. select n.N102_NAME as name, n.N301_ADDRESSONE +' '+n.N302_ADDRESSTWO +' '+n.N401_CITY +', '+n.N402_STATE +' '+ n.N403_ZIP as address ,d.REF02_SL_SALESMANNUM as salesman_num...
  8. tonydismukes

    Server: Msg 8624, Level 16, State 21, Line 1 Internal SQL Server error

    OK, I cleared out the extra start/end dates. select name, address, salesman_num,description, (select ISNULL(SUM(v1.qty),0) from ViewForCustom867Download v1 where v1.customerkey = v0.customerkey and v1.name = v0.name and v1.address = v0.address and v1.salesman_num = v0.salesman_num and...
  9. tonydismukes

    Server: Msg 8624, Level 16, State 21, Line 1 Internal SQL Server error

    Thanks, I'll try that. To clarify, I had no problem installing SP4. It's just that SP4 didn't fix the problem. Tony
  10. tonydismukes

    Server: Msg 8624, Level 16, State 21, Line 1 Internal SQL Server error

    I have the apparently redundant start/end dates because the query is dynamically built based on a user supplied start/end date, but I'm also grouping the results by month. In the example above, I supplied a start date of 1-1-2005 and end date of 2-11-2005. I suppose that I could put some extra...
  11. tonydismukes

    Server: Msg 8624, Level 16, State 21, Line 1 Internal SQL Server error

    Thanks for the suggestion, Leigh. I checked the event log and didn't find anything.
  12. tonydismukes

    Server: Msg 8624, Level 16, State 21, Line 1 Internal SQL Server error

    I have a view: CREATE VIEW ViewForCustom867Download AS SELECT h.customerkey, d.REF02_SL_SALESMANNUM as salesman_num, d.PID05_F_ITEMDESC as description, convert(int,d.QTY02_39_SHIPPEDQTY) as qty,d.LIN_UA_UPCCASECODE as upc, convert(datetime,h.DTM02_035_DeliveryDate) as DeliveryDate...
  13. tonydismukes

    Can I dynamically select a database in a stored procedure?

    Hmmm, that's getting closer. Now, however, when the script reaches the EXEC (@SQL_Command) line, it gives me the following message: Server: Msg 137, Level 15, State 1, Line 1 Must declare the variable '@fooCount'. @fooCount is previously declared in my script, and I can access it before and...
  14. tonydismukes

    Can I dynamically select a database in a stored procedure?

    Steve - thanks, but in the actual application, I have to select a particular list of databases based on customer ID and a particular table for each DB. A stored procedure which goes through every database on the server doesn't help me. Jay - the code you present builds the appropriate string...
  15. tonydismukes

    Can I dynamically select a database in a stored procedure?

    I'm trying to clean up some highly inefficient ColdFusion code which loops through a long list of databases, running dynamically built SQL queries on each one. I'm considering moving the entire process into a stored procedure and would like to do something like the following: /* simplified...

Part and Inventory Search

Back
Top