Hi All,
I am using Access 2003 and I want to show in my query all columns from a table that have values. Its probably a simple question but I have not been able to crack it so far.
My code is below, but it won't give me any of my columns.
SELECT IIf([Data table].[ID]= Not Null,"[Data table].[ID]) AS ID",IIf([Data table].[Attribute 1]= Not Null,"[Data table].[Attribute 1] AS Attribute_1",""))
FROM [Data table];
Thanks a lot!
Remaniak
8 4014
Try this ... -
SELECT [ID], [Attribute 1]
-
FROM [Data table]
-
WHERE [ID] Is Not Null
-
AND [Attribute 1] Is Not Null;
-
Try this ... -
SELECT [ID], [Attribute 1]
-
FROM [Data table]
-
WHERE [ID] Is Not Null
-
AND [Attribute 1] Is Not Null;
-
Hi McCarthy,
Thanks for your reply, but this will only give me all rows where Attribute and ID are both empty. But I want the query to skip the column if all of its rows are empty.
Would that be possible as well?
NeoPa 32,556
Expert Mod 16PB
No I'm afraid not.
There is no facility in SQL to determine columns dynamically.
Hi McCarthy,
Thanks for your reply, but this will only give me all rows where Attribute and ID are both empty. But I want the query to skip the column if all of its rows are empty.
Would that be possible as well?
This should be returning records where neither column is empty.
Mary
This should be returning records where neither column is empty.
Mary
Hi Mary,
You were right, it returns everthing where both column are not empty.
But there are no ways of constructing a piece of VBA code to build such a query?
Hi Mary,
You were right, it returns everthing where both column are not empty.
But there are no ways of constructing a piece of VBA code to build such a query?
Remaniak
What exactly do you want your query to return and where do you want the returned records displayed.
Mary
Remaniak
What exactly do you want your query to return and where do you want the returned records displayed.
Mary
I want the query to return my table with only the columns that have values in them. (some have a header but no values)
From that query I will then make an export.
I want the query to return my table with only the columns that have values in them. (some have a header but no values)
From that query I will then make an export.
Even if you built that kind of code which would be very complicated you would then have a report based on the results. For example there may be 5 columns. What happens if the next time there are 6 columns. Your report only has 5. Doing what you are suggesting is extremely complicated and in all honesty I'm not sure how it would work.
If you change the AND in the select statement I gave you previously to an OR it will at least only return those records where at least one of the columns has a value.
Mary
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Florian |
last post by:
Hi,
I have a table that contains log data, usually around a million records. The
table has about 10 columns with various attributes of the logged data,
nothing special. We're using SQL Server...
|
by: gary b |
last post by:
Hello
When I use a PreparedStatement (in jdbc) with the following query:
SELECT store_groups_id
FROM store_groups
WHERE store_groups_id IS NOT NULL
AND type = ?
ORDER BY group_name
|
by: mark.a.lemoine |
last post by:
Our application currently interfaces to SQL Server and Oracle, we're
implementing it into DB2 currently and I have a question to ask.
First a little background - We're interfacing into DB2 v8 on...
|
by: mark.a.lemoine |
last post by:
Our application currently interfaces to SQL Server and Oracle, we're
implementing it into DB2 currently and I have a question to ask.
First a little background - We're interfacing into DB2 v8 on...
|
by: MMcCarthy |
last post by:
To view Access queries in SQL rather than Access query design - open the query design window and change the view to SQL:
Select Statement
SELECT FROM ;
Append Statement
INSERT INTO (, , )...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |