|
Why would you want to design a system like this? I'm not really sure that I understand what you are trying to achieve here.
The only way offhand that I could think to do this would be to create a temporary table and use some form of dynamic SQL to return just the columns that didn't have an entry. It seems a bit useless to me though, because running the same query two days in a row could result in you retrieving columns that you weren't expecting.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I'm not sure why you would want to not return a whole column if one of the rows contained a null value in the column?
So I'm taking a risk and guessing you mean don't return the row if the column contains a null.
In which case:
How about this?
<br />
select name,isnull(occupation,'yadayadayada'),age<br />
from persons<br />
where occupation <> 'yadayadayada'
or
<br />
select name,occupation,age<br />
from persons<br />
where occupation is not null
Both of these should work.
You mention select * so to achieve this you would need to turn the first example into a view, the second example you could just replace the selected columns with an *.
I hope this helps...
You always pass failure on the way to success.
|
|
|
|
|
guys please help me on how to create a local search engine for my website..thank you.. for example, the user can search for the different products that my website is selling..
|
|
|
|
|
LyndonJohn wrote: the user can search for the different products
You can probably have 2 tables
Table1
ProductID
ProductName
Table2
ProductID
Description
Price
When the user wants to search details pertaining to a product, you may map it onto table2 based on ProductID and fetch the corresponding info.
|
|
|
|
|
For what? Local restaurants? Local singles? ...
|
|
|
|
|
i mean in local website..the user can just search the product within the system...G?
|
|
|
|
|
Hey guys
Not sure if this is the appropriate forum but let me give it a go anyways.
I’m trying to simulate triggers in MS Access 2003 from a .NET platform using C#. Is there anybody out there that perhaps faced the same challenge and if so can you please give me some guideline where to start.
Any background, information of guidelines will be highly appreciated.
Thanks.
R
|
|
|
|
|
hi every body I hope you are all fine.
I have project in asp 2.0 and database oracle10g and i want to preview the fields that in the last 6 month only.
i just want the query in sql thx in advance.
let's work together
|
|
|
|
|
How can anyone help you when you haven't given details of your tables/fields?
Paul Marfleet
|
|
|
|
|
select cast( month(getdate()) as varchar), cast(month(getdate())-6 as varchar)
I Love SQL
|
|
|
|
|
hi i m ajay rathi..i m facing a problem in group by clause in sql query..plz any one of u help me
The problem is... following are 3 queries and i need to combine all three queries into one query..because this time these queries are giving me data in three table and i am showing this data in repeater in ASP.NET with SQL SERVER 2003..
select count(*)as active from tbl_Post_Job where Company_Id_Fk = 60
and Status = 'Active' and Post_Date between '01/01/2007' and '01/01/2008' group by year(Post_Date), month(Post_Date)
select count(*)as billed from tbl_Post_Job where Company_Id_Fk = 60
and Status = 'Inactive' and Post_Date between '01/01/2007' and '01/01/2008'
group by year(Post_Date), month(Post_Date)
select count(*)as billed , month(Post_Date) as month_date ,year(Post_Date)as year_date from tbl_Post_Job where Company_Id_Fk = 60 and Status='Inactive' group by year(Post_Date), month(Post_Date)
actually the main problem i m facing is this that when i need month and year together and active postion and billed position saperatlly..
actually i need this data in following form...
Date | Active | Billed
------------------------------------
9,2007 | 4 | 8
10,2007 | 7 | 2
12,2007 | 6 | 6
------------------------------------
please if any one of you can help me it's very good for me plzzzzzzzzzzzzzz
thanks
Ajay Rathi
software engineer
NOIDA(UP),INDIA
|
|
|
|
|
Hi Ajay
Try something like:
select month(Post_Date) as Post_Month,
year(Post_Date) as Post_Year,
sum(case when Status = 'Active' then 1 else 0 end) as Active,
sum(case when Status = 'Inactive' then 1 else 0 end) as Billed
from tbl_Post_Job
where Company_Id_Fk = 60
group by year(Post_Date), month(Post_Date)
order by year(Post_Date), month(Post_Date) The case expressions allow you to count the number of rows that match their criteria.
Regards
Andy
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message".
|
|
|
|
|
thx a lot of thx it's working
u gave me a big support....
but i have one more problem related to this problem...actually when i m using that query which u gave me that is not working when i m using a sub query in that query ...
following is that query..
sum(case when Type_of_view like 'Applicants' and Posting_Id_Fk in
(select Id_PK from tbl_Post_Job where Company_Id_Fk = @Company_Id_Fk and Job_Title like @Job_Title and Job_Type like @Job_Type and Job_Location like @Job_Location ) then 1 else 0 end) as Applicants,
in this query i know the value of @Company_Id_Fk, @Job_Type, @Job_Location ,@Job_Title
Ajay Rathi
software engineer
NOIDA(UP),INDIA
|
|
|
|
|
Hi,
I have 3 tables: City_master(cityid(PK),cityname), zone_master(zoneid(PK),zname,cityid(FK)) and city_x_zone(czid(PK),cityid(FK),zoneid(FK).
I am running a join query to get the cityid and zone id into city_x_zone.the query is something like this:
select a.cityid,b.zoneid from city_master as a inner join zone_master as b on a.cityid=b.cityid where cityname='tb1.text' and zname='tb2.text'
I am running an insert query for city_x_zone like this:
insert into cityzone values(newid(),select a.cityid,b.zoneid from city_master as a inner join zone_master as b on a.cityid=b.cityid where cityname='Bangalo' and zname='south')
this is throwing an error.
What can be the solution to this?
Regards,
Anuradha
|
|
|
|
|
Try something like:
insert into cityzone
select a.cityid,b.zoneid from city_master as a inner join zone_master as b on a.cityid=b.cityid where cityname='Bangalo' and zname='south'
|
|
|
|
|
Hi All,
Iam having two tables
table1
1.Rno Primary key
2.name
3.empid foreign key of table2
table2
1. empid primary key
2.address
3.Rno foreign key of table1
Here Rno and empid are auto generated. Now i want to insert data into first table i need sql query for this.Please help me on this
i want to join this group
|
|
|
|
|
veereshIndia wrote: i want to insert data into first table i need sql query for this
INSERT INTO tblEmployee(
EmpolyeeID,
EmployeeName)
VALUES(
@EmpolyeeID,
@EmployeeName)
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Hi,
Please see my question once again.
Regard's
veeresh
i want to join this group
|
|
|
|
|
To Insert Into First Table
INSERT INTO tblEmp1(
EmpID,
EmpName
)
VALUES(
@EmpID,
@EmpName
)
To Insert Into Second Table
<code>INSERT INTO tblEmp2(
RowID,
EmpAddress,
)
VALUES(
@RowID,
@EmpAddress
)</code>
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
both insert statements results in violation of foreign key constraint
Regards
KP
|
|
|
|
|
Table Relationship's are Violating the Normalization Rule.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
disable constraint then a dummy master data.
use the same while inserting into transaction table.
Regards
KP
|
|
|
|
|
Inserting Into these table's are possible only If one of the table's Foreign Key column Allows Null Value.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
You have two foreign keys, each referencing the primary key of the other table. Why do you have this circular reference?
Makes inserting records a little awkward...
|
|
|
|
|
You are right.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|