@Date is your parameter @DateStart, convert the Dateformat, so that you can strip it out and select which ever datepart you want, like year, month, days. the concatination separates the date part, to be able to easily select
like select contractID from XXX
where @DateStart between 01-10-2007 to 03-12-2007
plz somone help me write these queries..
i want to search the data's from employee select the employee name,designation_name
1)employee code that i can pass or else designation name i can pass
2)only one i can pass from theses 2
3)the employee can contain null value for desination name
4)constraint is :employee.designation_id=desig.designation_id
plz somone help me out to solve this pblm
select employee.name, designation.name
left outer join designation
on designation.designation_id = employee.designation_id
where employee.code = IsNull(@EmployeeCode, employee.code)
and IsNull(designation.name, '') = IsNull(@DesignationName, designation.name)
order by employee.name
The outer join links the two tables together - even if there is no designation.
The IsNull bit allows you to optionally pass in a NULL or a proper value for the employee code and the designation.
I have these (amongst others) tables in my database:
Tasks and Successors
Tasks hold details about task, and Successors has two taskIDs as forgien keys (jointly primary key) to hold data on the relationship between task.
Ie Task A has Tasks B and C as successors.
Task Table has three records for the task. The Successor table has TaskA/B and TaskA/C primary key feilds.
I'm using this on a C# Clone of MS Project. So I'm reading this data in and converting them into classes, in a tree structure so each Task Object has a List<task> of successors.
I can read this data in fine by just parsing the data in the tables. The problem comes when I want to put newly created data into the database, which is stored in this tree of instances of Task.
[b]If I put add a Task record into the database, how do I get the primary key of the one I've just put in so that I can create the records in the successor table to link them?[/b]
In my example I will probably have to added the tasks 1st so that when I add the successor records, the tasks actually exists. The algorithim for this will be quite simple if I was able to get the primary keys when I adding the tasks.
group by statement might work if i have an aggregate statement somewhere, now there isnt i cant do the group by
i am trying distinct now, but i get incorrect syntax SELECT g.Maximum, distinct posnumber from out_pumptable, (SELECT MAX(flow_lpm) as Maximum, posnumber FROM out_pumptable GROUP BY posnumber)g WHERE flow_lpm = g.Maximum
SELECT g.Maximum, out_pumptable.posnumber from out_pumptable, (SELECT MAX(flow_lpm) as Maximum, posnumber FROM out_pumptable GROUP BY posnumber)g WHERE flow_lpm = g.Maximum group by g.Maximum, out_pumptable.posnumber
I believe you need to join the table to a subset of itself.
You create a subquery that gives you the values of project and the highest col1 and attribute that to a temptable. You then join you orignal table to your temp table on the values of col1. This should do the trick!
SELECT PT.* FROM out_pumptable PT join
(select project, max(col1) as MaxVal from out_pumptable group by project) TEMPTABLE1 on TEMPTABLE1.MaxVal = PT.col1
Last Visit: 31-Dec-99 19:00 Last Update: 6-Dec-22 17:07