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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incremental values!!!

Status
Not open for further replies.

ADW

Programmer
Jun 21, 2001
50
GB
Anybody Help? What I want to do is return values for every 7 days. For example, I want to return all transaction information on a weekly basis. How can I increment my SQL(Transact) statement?

select distinct transaction_type, Total = count(all transaction_type), Total_Quantity = sum(all movement_quantity) from st_history
where transaction_type != 'ADJ'
and transaction_type != 'TRAN'
and transaction_type != 'SCRP'
and transaction_type != 'BINT'
and transaction_type != 'SRET'
and transaction_type != 'DESP'
and transaction_type != 'RINV'
and transaction_type != 'SALE'
and dated > '2000-07-01'

group by transaction_type
order by transaction_type
 
Hi ADW,

I am not very sure what you asked. But may be seeing the following snippet you get some help.
--------------------------------
select distinct transaction_type, Total = count(all transaction_type), Total_Quantity = sum(all movement_quantity) from st_history
where transaction_type != 'ADJ'
and transaction_type != 'TRAN'
and transaction_type != 'SCRP'
and transaction_type != 'BINT'
and transaction_type != 'SRET'
and transaction_type != 'DESP'
and transaction_type != 'RINV'
and transaction_type != 'SALE'
and dated > dateadd(dd,-7,getDate())
group by transaction_type
order by transaction_type
------------------------------------
or
Creating a weekly schedule with this SQL, which will insert this selected data in some temporary table on weekly basis.

If you asked something else, let us know.
 
Hi ADW,
Sorry for not writing this in previous one.
If you want to select all the data week wise you can issue following query :
----------------------------
select distinct Week=datepart(wk,dated),
transaction_type, Total = count(all transaction_type), Total_Quantity = sum(all movement_quantity) from st_history
where transaction_type not in
('ADJ','TRAN','SCRP','BINT','SRET','DESP','RINV','SALE')
and dated > '2000-07-01'
group by datepart(wk,dated),transaction_type
----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top