#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default SQL Query

Hi All,

How can I Group data in an Sql query based on month while
the data on the table is based on Date?

For Eg.

Day Item Sales Purchase Amount


TIA
Soniya
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default SQL Query

Soniya

This sound like a perfect scenario for a pivot table. Take the option
DataPivot table report and navigate to the sql table or view. This will
bring the data to the pivot table designer.

Drag the Day and Item fields as row fields and then the others as values

Once you have them in as day data right click on the Day header and select
Group. Select Months and if there is more than one year's worth, select
years as well.

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Soniya" wrote in message
...
Hi All,

How can I Group data in an Sql query based on month while
the data on the table is based on Date?

For Eg.

Day Item Sales Purchase Amount


TIA
Soniya



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default SQL Query

Some hints:

Can't tell what your data looks like or where its is held i.e. Excel,
Access, SQL Server , Oracle or ?.

For SQL Server, (should also work when using Jet 4.0 (i.e. text, Excel,
Access), a solution is:

select distinct(dob),
count(membno) as Freq,
month(dob) as mth ,
sum(spa) as totspa
from basic
group by month(dob),dob,spa

where
basic = the table
dob = a date (date of birth)
membno = numeric, distinct on each row (same for character data)
spa = numeric, an amount that can be summed.

You can try to adapt this to your data.

"Soniya" wrote:

Hi All,

How can I Group data in an Sql query based on month while
the data on the table is based on Date?

For Eg.

Day Item Sales Purchase Amount


TIA
Soniya

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import New Database Query (Union Query) in Spreadsheet klock Excel Discussion (Misc queries) 2 September 24th 09 01:30 AM
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Importing Data via Web Query - Can values be passed to query? [email protected] Excel Discussion (Misc queries) 5 May 9th 06 06:21 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


All times are GMT +1. The time now is 01:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"