I need to query statement to list all tables from a database containing a given column name
in TransBase.
Thank you very much in advance.
select * from syscolumn col
inner join systable tbl on tbl.segno=col.tsegno
where col.cname like '%col_name%';
That was quick! For everybody that might need this in future.
Related
I have an Excel spreadsheet which I use as a relational database for my milk round. I query this database using MS Query in Excel (Mac 2011 Version) to generate my delivery routes. One of the columns is the customer address and I'd like to have this shown once per order i.e. have a distinct query for just this column while displaying multiple other rows. It's purely for cosmetic purposes to make the spreadsheet less cluttered.
The main spreadsheet I use as my database has column headings which I have screenshotted, complete with some sample data:
From this main spreadsheet I use MS Query to generate my delivery route which looks like this:
As you can see there is a lot of repeated data in the route generated from the query. What I'd like to do is have just one instance of the address per customer's order, it would help with the legibility of the route when opened in an iPad. I hide other columns that aren't really necessary to help in that regard.
*EDIT
From isolated's comments below, here's a screenshot of ideally how the data returned from the query should look:
I've manually deleted the repeated info in the name & address column to achieve the desired result. I've also hidden some columns that aren't really necessary and I use some conditional formatting rules to help distinguish each customer's order.
EDIT*
I have tried using a group by clause and the following window function but can't get it to work:
SELECT *
FROM (
SELECT “All Orders”.”Route ID”,
“All Orders”.Name,
“All Orders”.Address
ROW_NUMBER() OVER(PARTITION BY “All Orders”.Address
ORDER BY “All Orders”.Address DESC) AS row_number
FROM “All Orders”
) AS rows
WHERE row_number = 1;
Whenever I try to run the query I get an error message regarding syntax. Hopefully someone can tell me where I'm going wrong!
I don't know MS Sql at all, but you could do something with a formula in excel. If you don't like this solution, simply put a comment below that you would still like a sql route and I can get you a query to try to adapt to ms sql.
Create another column and call it address2 (or several more columns if your address field is multiple columns).
Then use this/these formula and adjust as needed:
Column F (address2): =IF(A2=A1,"",C2)
Column G (town2): =IF(A2=A1,"",D2)
You can then hide columns C and D.
=============
U P D A T E
Here's a method that works in many dbms such as postgres, but I don't know how to adapt [rank() over (partition by...] to excel sql.
select account,
cust_name,
item,
case
when prod_rank = 1 then address
else ''
end address
from (
select
account,
cust_name,
item,
address,
rank() over (partition by account order by item) as prod_rank
from table1
)z
order by account, item
I tried a few variations in excel sql and finally got this one to work.
select a.Account,
a.Name,
a.Product,
Iif(a.product = b.min_item,a.address,'') as [address]
FROM table1 as a
,(
select
z.Account,
min(z.Product) as min_item
FROM table1 as z
group by z.Account ) as b
where b.account = a.Account
order by a.account, a.product
I'm trying to build a kind of timeline based on a table in Excel. The table has several columns that represent a due date. Column A is considered the key/identifier, Column B is a company name, Columns C through H are the task due dates.
My goal is to hopefully find a way to setup a second type of table that will automatically set the items in order of what key is due when. I've included an img of the table and what I'm hoping the end result would be. I haven't been able to find anything that does this. I was thinking maybe a pivot table but it's not doing what I want.
I'm not even sure if this is possible or not but any help or push in the right direction would be GREATLY appreciated!
Thanks!!
-Deke
You can easily do this with Power Query. Just load the table, sort on date, and select which columns you want
My first post/question here, I have searched and tried many options but nothing seems to fit exactly what I need.
I am building an Access DB to manage scheduling work and assigning employees to that work. The Scheduled work comes from an Excel Sheet that I've imported into Access. I don't have control over how the data comes to me or the format.
So I have a table 'tblTempP6' with the scheduled work for the year. Several columns determine a unique entry.
I have another table 'shtP6DataEast' has an index which is the primary key. the two tables are the same except shtP6DataEast entries has and index. so i can access specific entries and assign employees etc..
Each time i get a new sheet to import the existing scheduled work is still in the sheet and i dont want duplicate entries with different ids.
I have tried Left Joins but have had issues because i need to use 4 columns as the unique identifier...
Any thought?
Thanks
forgive my NOOB Question
SELECT tblTempP6.[Project #], tblTempP6.[Work Order #], tblTempP6.[Project Name], tblTempP6.[Activity Name], tblTempP6.[TOA #], tblTempP6.Start, tblTempP6.Finish, tblTempP6.[Budgeted Labor Units], tblTempP6.[S/S - SUBSTATION], tblTempP6.iCircuit, tblTempP6.isStreet, tblTempP6.[Test Group Work Type], tblTempP6.Comments, tblTempP6.[Resource IDs]
FROM tblTempP6
LEFT JOIN shtP6DataEast ON tblTempP6.[Project Name] = shtP6DataEast.[Project Name]
WHERE (((shtP6DataEast.[Project Name]) Is Null));
Well I will try to answer this generally, using tmp as the name of the table with the freshly imported and possibly duplicated data, and dat as the name of the table with the previously imported, permanent data.
There's a bunch of ways to do it, here's how to do it with LEFT JOIN:
SELECT *
FROM tmp
LEFT JOIN dat ON tmp.KeyCol1 = dat.KeyCol1
AND tmp.KeyCol2 = dat.KeyCol2
AND tmp.KeyCol3 = dat.KeyCol3
AND tmp.KeyCol4 = dat.KeyCol4
WHERE dat.IDcol IS NULL
You do the left join against the existing data, and then exclude all rows that actually matched to that table.
I have been looking into this issue for some time and need some help. I have looked into sub-queries and CTE with no Luck.
I want to create a select of all of the data in Table A. I also want to add some columns from Table B. So an Inner join will work initially.
However in Table B I want to create a string that is concatenated from all the different categories for each person and list this as a column in my select.
For example, one person might be in IT and also Construction categories so I would like a string that says "Construction, IT" listed for that person and the same basis for all others.
I believe I have looked into COALESCE
which meets me part way. Any advice most appreciated.
Table A
Name
Surname
Person Ref
Table B
Person Ref
Person Category
Person Gender
These are example tables I can't post the ones I'm looking at for security reasons but hopefully, you get my point.
Martin
Maybe I'm missing something simple, but is there a way to write a nested query in AX? I tried some syntax I thought would work, but with no luck.
The following standard SQL statement would accomplish what I'm trying to do, but I need to do this in AX, not SQL.
SELECT table1.column1A, table1.column1B,
(SELECT Top 1 column2B FROM table2
WHERE table1.column1A = table2.column2A
ORDER BY table2.column1A)
AS lookupResult
FROM table1
My problem is that table1 has a one-to-many relationship with table2, and since AX doesn't have a DISTINCT function that I'm aware of, I receive many copies of each record when using a JOIN statement.
Thanks
Nested queries are not supported in AX.
One way to bypass the missing distinct is to use group by (assuming max value of column2B is interesting):
while select column1A, column1B from table1
group column1A, column1B
join max-of(column2B) from table2
where table2.column2A == table1.column1A
{
...
}
Another method would be use a display method on table1 in the form or report.
display ColumnB column2B()
{
return (select max-of(column2B) from table2
where table2.column2A == this.column1A).column2A;
}
The performance is inferior to the first solution, but it may be acceptable.
As mentioned in the previous reply, group-by is the closest you can get to a distinct function. If you need a simpler query for some reason, or if you need a table or query object to use as a datasource on a form or report, you may entertain the idea of creating a view in the AOT, which contains the group-by. You can then use that view to easily join to on a query object or form datasource etc...
Ax2012 has support of computed columns in views, you can use the SysComputedColumn class to build query you want