2012年2月26日星期日

First Date in the Month

I have a question about creating view for these coloum and have a lot trouble, before that I describe my tables :

Table A :
Code as nvarchar
Ammount1 as money
Date as datetime -> transaction date
primary key are Code and Date1

Table B :
Code as nvarchar
Ammount2 as money
Date as datetime -> transaction date
primary key are Code and Date2

I like joining this table and create table/view that result :

Code | Amount1 Today | Amount2 Today | Amount1 Last Year | Amount1 Month to date (Sum from first day month till today) | Amount2 month to date | Amount1 Last Year month to date

The parameter only for @.Date.

First I have problem to get queries specially for first date in the month, I used CAST but it doesn't work, then I used CONVERT and CAST still doesn't work.

Anybody help me ?
Thx a lot.
ad1k4r4You can't pass an argument to a SQL view. You probably want to use a stored procedure if your database engine supports them.

-PatP|||Originally posted by Pat Phelan
You can't pass an argument to a SQL view. You probably want to use a stored procedure if your database engine supports them.

-PatP|||I know that Tony (the SQL Forum moderator) likes to keep this forum free of database engine specific discussions, and I think this particular discussion may be long. This has really become a thread that belongs in the SQL Server Forum (http://www.dbforums.com/f7/). I'll be happy to pursue it there (as will many other people)!

-PatP

没有评论:

发表评论