Re: Advanced SQL - Extracting values by months
- From: whitsey <lysterfieldcc@xxxxxxxxx>
- Date: 28 May 2007 20:52:46 -0700
On May 29, 12:23 am, "David Cressey" <cresse...@xxxxxxxxxxx> wrote:
"whitsey" <lysterfiel...@xxxxxxxxx> wrote in message
news:1180340909.593482.109010@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Help!
I am trying to write an SQL statement (without much luck) to extract
the total number of searches and orders from a particular customer,
grouped into days/months/weeks (depending on the report type.
The tables are as follows:
Searches
--------------
search_id (PKEY)
customer_id (FKEY)
product_id
cost
date
....
Orders
-----------
order_id (PKEY)
search_id (FKEY)
order_value
date
...
Groups
-----------
group_id (PKEY)
customer_id
...
Customers
---------------
customer_id (PKEY)
....
What I want to achieve from this is
For all customers with Group_id = '17'
Let's stop right here.
Customer_id should not be a column in the Groups table. The way you've
placed it, it looks like a customer can belong to many groups, but a group
can only have one customer in it. I doubt that this is your intent.
More likely would be a "group_id" column in the Customers table. Do you
agree?- Hide quoted text -
- Show quoted text -
I'm not having an issue with the table structure, it is the SQL
required to extract the information I want.
A Group can have multiple customers in it and a customer can be a part
of multiple groups.
.
- Follow-Ups:
- Re: Advanced SQL - Extracting values by months
- From: David Cressey
- Re: Advanced SQL - Extracting values by months
- From: Nis Jørgensen
- Re: Advanced SQL - Extracting values by months
- References:
- Advanced SQL - Extracting values by months
- From: whitsey
- Re: Advanced SQL - Extracting values by months
- From: David Cressey
- Advanced SQL - Extracting values by months
- Prev by Date: Postgre , MySQL or SQL Server ?
- Next by Date: Re: Advanced SQL - Extracting values by months
- Previous by thread: Re: Advanced SQL - Extracting values by months
- Next by thread: Re: Advanced SQL - Extracting values by months
- Index(es):
Relevant Pages
|