Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Difficulty querying tables with none existing ID in table2

 
   Database Help (Home) -> MSEQ RSS
Next:  open subform filtered  
Author Message
ITDUDE27

External


Since: Jan 24, 2008
Posts: 6



(Msg. 1) Posted: Thu Nov 20, 2008 12:47 pm
Post subject: Difficulty querying tables with none existing ID in table2
Archived from groups: microsoft>public>sqlserver>mseq (more info?)

I need some assistance querying some data for reporting purposes. This
report will capture sale promises made by customers to buy x number of an
item and capture how much the've actually used(qty_shipped). The main part of
this report is to capture a sum of all usage when a promise is for in house
account (account xyz), but account xyz does not exist in the table that has
usage. Can anyone help with how to form this query.

*** Table1:
Customer,
Customer_ID,
Item,
TotalQty,
BeginDate,
EndDate

*** Table2:
[customer_id] [decimal](19, 0) NULL ,
[customer_name] [varchar] (255) COLLATE Latin1_General_CI_AS_KS_WS
NULL ,
[date_created] [datetime] NOT NULL ,
[qty_shipped] [decimal](19, 9) NOT NULL ,
[inv_mast_uid] [int] NULL

*** Table3:
[inv_mast_uid] [int] NOT NULL ,
[item_id] [varchar] (40) COLLATE Latin1_General_CI_AS_KS_WS NOT NULL ,
[item_desc] [varchar] (40) COLLATE Latin1_General_CI_AS_KS_WS NOT NULL
Thanks in advance.

 >> Stay informed about: Difficulty querying tables with none existing ID in table2 
Back to top
Login to vote
Hugo Kornelis

External


Since: Jan 11, 2008
Posts: 440



(Msg. 2) Posted: Tue Nov 25, 2008 7:25 pm
Post subject: Re: Difficulty querying tables with none existing ID in table2 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Thu, 20 Nov 2008 12:47:04 -0800, ITDUDE27 wrote:

>I need some assistance querying some data for reporting purposes. This
>report will capture sale promises made by customers to buy x number of an
>item and capture how much the've actually used(qty_shipped). The main part of
>this report is to capture a sum of all usage when a promise is for in house
>account (account xyz), but account xyz does not exist in the table that has
>usage. Can anyone help with how to form this query.

Hi ITDUDE27,

I think I can - but not with the data you supplied, as I have great
difficulty figuring out which table equates to what entity in your
description, and how the tables relate. So can you please post:

* The layout of your tables, **in the form of CREATE TABLE statements**.
Please include all constraints, properties, and indexes; you may omit
irrelevant columns though.

* A few well-chosen rows to illustrate the situation, including all
relevant possible variations and combinations. Please post this sample
data as INSERT statements that I can cut and paste into my database
after running the CREATE TABLE statements mentioned above (and try to
use consistent upper-/lowercase and nonambiguous date format, as I run
on a case sensitive server in a non-US country).

* The expected results, based on the sample data, along with an
explanation of any non-obvious results.

See www.aspfaq.com/5006 for more information.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

 >> Stay informed about: Difficulty querying tables with none existing ID in table2 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Producing data from querying three tables - Hi all, I'm trying to run a query that produces data from three tables, in essence these are Location, Category and BannerPeriod, They all have a secondary key of SiteID and are linked by this, really there are two stages to this query, Stage 1..

update querie multiple tables - Hi I wish to create a stored procedure that updates multiple tables. I have a table called User CREATE TABLE [dbo].[Users]( [UserId] [int] NULL, [Active] [bit] NULL, [OrganisationId] [int] NULL, [Username] [varchar](20), [Password] [varchar](20),....

Determining which tables are in which file group via T-SQL - I'm trying to figure out how to list what file group every table is in. I thought this query was it : select sys.tables.name,sys.data_spaces.name from sys.tables,sys.data_spaces where sys.tables.lob_data_space_id = sys.data_spaces.data_space_id order...

index on a view - Hello, I have a table (TAB) and A View with alias (VIEW) Table cod varchar 3 descr carchar 60 my view cod alias COd1 descr alias DES Now i need a index on view with key COD1 I can't create it. Can..

Creating an alias - I have an alias that can get very long because it maintains a information of where it came from. Is there a way to alias an alias? My first thought was: Declare @T1 varchar(128) Set T1 = 'MyAlias' .... Inner Join Table1 as @T1 This of course does no...
   Database Help (Home) -> MSEQ All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]