Customer SQL USING SELECT COUNT(*) in TABLEAU RETURNING ZERO - tableau-api

I'm using TABLEAU Datasource option to run Custom SQL "Select count() from table_name. It is based on a ODBC connection. Unfortunately, I have 400 tables that I need to run my script with 400 lines of "Select count()" , Tableau is not returning the total # of records and is only returning ZEROs. I'm using the Edit Custom SQL option from the Datasource Tab.
I have tried using the View Result after Opening the Edit Customer SQL and selecting the View Result to get the total count. My plan was to include all he 400 select counts in one script and run it. It worked fine as a part of my connection to another database but not ODBC.
SELECT COUNT(*) FROM ACCOUNTING_BOOKS
The expected result should be,
Select Edit Customer SQL
View Result
Get a listing of counts.

According to this answer count isn't available as a NetSuite function. You might want to follow the link in that article (if you have a NetSuite account) to see if this has changed.

Related

"#Error" when using Lookup in Microsoft Reporting 3.0

We are using Microsoft Reporting for generating a daily report. I want to add another column to one of the tables we have. Initially, I had set this up correctly and the report worked fine. However, due to technicalities I have to use a different table (with exact the same data) so I edited the query and once I do that I star getting "#Error" in the cell calues of my column.
The cell expression:
=Lookup(Fields!fldFlight.Value, Fields!OutboundFlightNumber.Value, Fields!OnTime.Value, "DataSet")
I use the following query to form DataSet:
SELECT
turnarounds_staging.OutboundFlightNumber
,turnarounds_staging.VisitDatabaseID AS [turnarounds_staging VisitDatabaseID]
,turnarounds_staging.STDDate
,events_staging.VisitDatabaseID AS [events_staging VisitDatabaseID]
,events_staging.OnTime
,events_staging.Event
FROM
turnarounds_staging
LEFT OUTER JOIN events_staging
ON turnarounds_staging.VisitDatabaseID = events_staging.VisitDatabaseID
WHERE
events_staging.Event ='PDC'AND
turnarounds_staging.STDDate= #Date
Where #Date is a parameter indicating yesterday.
If I change the query to the original table (identical). It works fine.
Any ideas why this happens when turnarounds_staging is identical to the original table?

Crystal Reports - Using Report Data as Sql Command Parameter

I'm hoping someone here might be able to help me with a Crystal Reports problem that's been bugging me on and off for days.
I have a report that is used as a picking slip for our warehouse staff to tell them which products to pack for each order that comes through our sales system.
The report contains all the products for the order and the quantities that need to be packed in the details section of the report which come from a number of joined tables.
My problem is that I have to then query the database again in order to get the total amount of items for each product on the order that have been packed across all orders throughout the warehouse.
The report datasource only returns records relating to the order on the picking slip so I need a sub query.
I've tried to use a SQL command with the following query:
SELECT ISNULL(SUM(QtyPacked), 0)
FROM tblPackingSlipLines
WHERE Status = 'Packed'
AND ProductId = '[ProductId]'
I'm stuck on passing the product id into the command as it is held in a text field on the report itself which is populated from tblProducts.ProductId (one of the joined tables).
Is it even possible to access this value from the command?
I've tried things like ProductId = '{tblProducts.ProductId}', #ProductId, ?ProductId and numerous other weird and wonderful permutations.
I can't use a parameter as that would require either user interaction; not possible as the report is auto generated by a Windows service or passing a static value in from the service.
I've also tried using a formula but that only pulls back the sum of QtyPacked for that distinct order line and not all packed orders in the DB:
SUM('{tblPickingSlipLines.QtyPacked}', '{tblProducts.ProductId}')
Any help would be greatly appreciated.
try using the sub report for this purpose.
Write your second query in sub report and pass the tblProducts.ProductId to the record selection parameter of the sub report through sub report links now your query comes in sub report as:
SELECT ISNULL(SUM(QtyPacked), 0)
FROM tblPackingSlipLines
WHERE Status = 'Packed'
AND ProductId = {pm-product ID}

See length (count) of query results in workbench

I just started using MySQL Workbench (6.1). The default limit for queries is 1,000 and that's fine I want to keep that.
But the results from the action output message will therefore always say "1000 rows returned".
Is there a setting to see the number of records that would be returned in the query had their been no limit? For sanity checking query results?
I know this is late by a few years, but I think you're asking for a way to see total row count in the bottom of the results pane, like in SQL Server. In SQL Server, you would also go in the messages pane and it would say how many rows were returned. I was actually looking for exactly what you were asking for as well, and seems like there is no way to find that. If you have an ID in your table that is just numeric and is in numeric order, you could order by ID desc and look at the biggest number there. That is what I've decided to do.
The result is not always "1000 rows returned". If there are less records than that you will get the actual count. If you want to know the total number of rows in a table do a select count(*) from table. Alternatively, you can switch off the automatic limit and have all records returned by MySQL Workbench, but that can be time + memory consuming for large tables.
I think removing the row limit will help. By default, MySQL workbench will limit the result set to 1000 rows but you can always disable the limit. Check out https://superuser.com/questions/240291/how-to-remove-1000-row-limit-in-mysql-workbench-queries on how to do that.
You can run a second query to check that
select count(*) from (your original query) as t;
this will return the total rows in actual result.
You can use the SQL count function. It returns the count of the total number of rows a query returns.
A sample query:
select count(*) from tableName where field1 = value1
In workbench, in the dropdown menu at the top, set it to dont limit Then run the query to extract data from table Then under the output pane below, the total count of the query results will be displayed in the message column

Reporting on multiple tables independently in Crystal Reports 11

I am using Crystal Reports Developer Studio to create a report that reports on two different tables, let them be "ATable" and "BTable". For my simplest task, I would like to report the count of each table by using Total Running Fields. I created one for ATable (Called ATableTRF) and when I post it on my report this is what happens:
1) The SQL Query (Show SQL Query) shows:
SELECT "ATABLE"."ATABLE_KEY"
FROM "DB"."ATABLE" "ATABLE"
2) The total records read is the number of records in ATable.
3) The number I get is correct (total records in ATable).
Same goes for BTableTRF, if I remove ATableTRF I get:
1) The SQL Query (Show SQL Query) shows:
SELECT "BTABLE"."BTABLE_KEY"
FROM "DB"."BTABLE" "BTABLE"
2) The total records read is the number of records in BTable.
3) The number I get is correct (total records in BTable).
The problems starts when I just put both fields on the reports. What happens then is that I get the two queries one after another (since the tables are not linked in crystal reports):
SELECT "ATABLE"."ATABLE_KEY"
FROM "DB"."ATABLE" "ATABLE"
SELECT "BTABLE"."BTABLE_KEY"
FROM "DB"."BTABLE" "BTABLE"
And the number of record read is far larger than each of the tables - it doesn't stop. I would verify it's count(ATable)xcount(BTable) but that would exceed my computer's limitation (probably - one is around 300k rows the other around 900k rows).
I would just like to report the count of the two tables. No interaction is needed - but crystal somehow enforces an interaction.
Can anyone help with that?
Thanks!
Unless there is some join describing the two tables' relationship, then the result will be a Cartesian product. Try just using two subqueries, either via a SQL Command or as individual SQL expressions, to get the row counts. Ex:
select count(distinct ATABLE_KEY) from ATABLE
If you're not interested in anything else in these tables aside from the row counts, then there's no reason to bring all those rows into Crystal - better to do the heavy lifting on the RDBMS.
You could UNION the two queries. This would give you one record set containing rows from each query once.

No data returned in Crystal Reports

I have a Crystal Report I'm working on; last week it was returning results but when I fired it up this morning I was no longer getting anything. Checking the SQL query, I show that the table name is listed twice, for some reason:
SELECT "WMS_TESTINFO"."RECORD_NAME"
FROM "TestEnv"."dbo"."WMS_TESTINFO" "WMS_TESTINFO"
Any thoughts on what could have broken? I've checked that the database is connected and my data is still there.
The table name is listed twice as Crystal Reports creates an alias for every table.
This Crystal generated SQL:
FROM "TestEnv"."dbo"."WMS_TESTINFO" "WMS_TESTINFO"
Is in the format of:
FROM DATABASE.OWNER.TABLENAME ALIAS
This is normal for Crystal.
I would run that SQL in SSMS (remembering to remove all of the " first) to check that the data really is still there.
If it is, check that a filter hasn't been added to the report, via the Select Expert menu opton, to filter out all the data.
Lastly, go to Database > Set Datasource Location and re-apply the connection to ensure that the report is definitely pointing at the right location.