MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 21st, 2008, 03:01 PM
DatSure DatSure is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 1 DatSure User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 34 sec
Reputation Power: 0
Question Query Assistance

Dear SQL Gurus:

None of us at our company are SQL query writers and have no clue what we are doing and thus my post. If someone could read the requirements and help me with a query I would really appreciate it!

I have a database called PPLNET in SQL Server 2000. I need to count the messages sent to and from a user as recorded in two tables. The table names are:

1. allinboundmessages
2. alloutboundmessages

Each of these two tables contains the following relevant fields:

1. vehicle_number
2. created_datetime

These two tables do not have any current relationship and we cannot change that. So we need to create a report that shows each vehicle, how many inbound messages were received, how many outbound messages were received, and then calculate a percentage showing the difference. Consider that the outbound should be twice what the inbound number of messages is.

How would I write such a query? I figured out how to use the BETWEEN and COUNT methods on each the inbound and out in total but not by driver. Again, any help is MUCH appreciated!

Sincerely,

Joshua

Reply With Quote
  #2  
Old July 21st, 2008, 03:47 PM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,826 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 1 Day 11 h 35 m 33 sec
Reputation Power: 278
Please confirm that a query like
sql Code:
Original - sql Code
  1. SELECT
  2.  vehicle_number,
  3.  COUNT(created_datetime)
  4. FROM
  5.  allinboundmessages
  6. GROUP BY
  7.  vehicle_number
does give you the desired count so that we can go on, stick the results together and compute the percentage

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Query Assistance


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway