|
|
Try a google search[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Hi ...
I have a table for eg called Forms (fid int , Read bit , Add bit , Del bit )
the problem that more than one row with the same Form like that :
fid - Read - Add - Del
2 - True - True - False
2 - True - False - False
2 - True - False - True
you can see that the form takes Add True and False in second row
.. I want to select only one row but if I have Add col has two value True and False in another row then select True to be :
2 - True - True - True
I'm using Sql server 2005 ,, can I create stored procedure do that ...
really thanks ...
jooooo
|
|
|
|
|
kindman_nb wrote: .. I want to select only one row but if I have Add col has two value True and False in another row then select True to be :
2 - True - True - True
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Can you be more descriptive in your question?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
You can create a stored procedure and handle this inside the procedure. However, your problem is in modelling. You should break the table to at least two table. Separate table for Forms and separate table for allowed operations. This way you can query what operations are allowed and those that are not allowed, are not listed.
Mika
|
|
|
|
|
Not sure what you mean, do you mean something like this?:
select fid,max(cast([read] as int)),max(cast([add] as int)),max(cast([del] as int)) from Forms group by fid
|
|
|
|
|
Thanks my friend ..
what I mean that for eg ..
I have users . every user is subscribe in group and every group has it's permission Read and Add and Del of all forms ...
user A is subscribe in Group M and N
for eg : customer form :
Group M Read true - Add True - Del False
Group N Read true - Add False - Del False
then i want to select the permission of the user a from the table of permestoin ..
you can see that the user has Add is true in group M and the same user has Add is false in group N
i want to select True if i hase true or false of the same permissoin ..
i hope if you see what mean
jooooo
|
|
|
|
|
Ah, OK, well what I posted should help.
|
|
|
|
|
Hi,
I have paradox database files which I need to migrate to SQL server database.I used the DTS and DataSources(ODBC) but I find the first selection :copy data from one or more tables disabled so I must use a sql query.But I don't know the tables names in the Paradox database files so What kind of query could I use?
I am too late but i will never give up
|
|
|
|
|
|
Hi,
I am using sql server 2005.
When I am finding difference between two date I am getting one day less
For example
select datediff(d , '2008-09-01' , '2008-09-05')
I am getting 4 days I want it to be five day as 1,2,3,4,5 that is it should start from date to todate
How can I do it
Please help
Thank you
imran khan
|
|
|
|
|
Add 1 to the result.
DateDiff gives you the interval between the two dates.
|
|
|
|
|
imranafsari wrote: select datediff(d , '2008-09-01' , '2008-09-05')
5 - 1 = 4
Seems ok to me...add 1 to get your desired result.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
select datediff(d , '2008-09-01' , '2008-09-05')+1
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
let it be
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hello Experts,
I have my data like below,
ID Fname Date_TimeWorked Status
1 MyName 2006-10-25 10:00:05 Ready
1 MYName 2006-10-25 11:00:05 Completed
1 MyName 2006-10-25 10:30:00
I want to know the time difference Between Ready-completed, ready-canceled.
How do I query this? Its urgent. Thanks in advance!!
|
|
|
|
|
For example:
SELECT DATEDIFF(minute, start.Date_TimeWorked, end.Date_TimeWorked) AS ElapsedMinutes
FROM TableName start,
TableName end
WHERE start.ID = end.ID
AND start.Status = 'Ready'
AND end.Status = 'Completed'
Mika
|
|
|
|
|
I have this in one table, what is TableName start,TableName end?
Thank you
|
|
|
|
|
Since I didn't know the actual name for your table I used only TableName. Let's say your table is named WorkData then the query would look like:
...
FROM WorkData start,
WorkData end
...
Start and end are aliases for the same table so that it can be referred twice. I used start alias (the alias can be whatever you want) for the row that defines the starting point for time and respectively end for ending point.
Hope this helps,
Mika
|
|
|
|
|
I just created a simple access database for it and tried, but it is prompting me Minute.. Entere Parameter value.
ID Fname Date_TimeWorked Status
1 MyName 2006-10-25 10:00:05 Ready
1 MYName 2006-10-25 11:00:05 Completed
1 MyName 2006-10-25 10:30:00 Cancled
|
|
|
|
|
The code was for SQL Server which most of the people here use. It's been ages since I last used Access, but try just subtracting the two times (end.Date_TimeWorked - start.Date_TimeWorked ). I'm not sure but it may give you the result you want.
|
|
|
|
|
Well I was playing with Excel sheets to database, so I was trying something on access database. and thank you for your reply, the query looks like it works.. but I got the idea which i was looking for, thanks 
|
|
|
|
|
You're welcome 
|
|
|
|
|
Hello Mika, I need your help on this query, you suggested me
SELECT DATEDIFF(minute, start.Date_TimeWorked, end.Date_TimeWorked) AS ElapsedMinutes
FROM TableName start,
TableName end
WHERE start.ID = end.ID
AND start.Status = 'Ready'
AND end.Status = 'Completed'
Ready-Complete ok, but I want one more condition added to it, I need
time between Date_Timeworked when status is Ready and Rejected?
|
|
|
|