Given below is the sample of my code. When I tried to switch to the design view it gives me an error:
"Microsoft Access can't represent the join expression a.Course_name=b.Course_name in Design view".
When I searched this error on stackoverflow I found one post. According to the post the solution is given in this link (http://support.microsoft.com/kb/207868). According to this link, try to remove extra parenthesis (especially nested parenthesis) and problem will be resolved. However, in my query I don't have nested parenthesis. So I don't know how to fix it. Any help would be appreciated.
SELECT a.Course_name, COUNT(b.Student_code) AS [Total], Format(b.Retrieved_date,"mmmm yyyy") AS [Month]
FROM Course AS a LEFT JOIN (SELECT b.Course_name, b.Student_code, b.Retrieved_date FROM pending-enrolment AS b WHERE b.Retrieved_date BETWEEN [Forms]![ParameterForm]![txtBeginDate] AND [Forms]![ParameterForm]![txtEndDate]) b
ON a.Course_name=b.Course_name
GROUP BY a.Course_name, b.Retrieved_date
;
Try the following code (tested and works 100%):
SELECT Course.Course_name, Count(b.Student_code) AS CountOfStudent_code,
Format([b].[Retrieved_date],"mmmm yyyy") AS [Month]
FROM Course
LEFT JOIN
(
SELECT [pending-enrolment].Course_name, [pending-enrolment].Student_code,
[pending-enrolment].Retrieved_date
FROM [pending-enrolment]
WHERE ([pending-enrolment].Retrieved_date
Between [Forms]![ParameterForm]![txtBeginDate]
And [Forms]![ParameterForm]![txtEndDate])
) AS b ON Course.Course_name = b.Course_name
GROUP BY Course.Course_name, Format([b].[Retrieved_date],"mmmm yyyy");
Related
I am tryin to resolve this situation. The following piece of code works ok .
SELECT FISCAL_START, DESCRIPTION,
CASE WHEN FISCAL_START BETWEEN DATE'2014-03-31' AND DATE'2014-09-29' THEN DESCRIPTION
ELSE 'Test Failed'
END
FROM GL_PERIOD
what I am trying to achieve is as follows instead of the hard coded dates of 2014-03-31 and 2014-09-29..need to replace those with column names FISCAL_START and FISCAL_END dates from an unconnected view call WORK.
Psuedo code is as follow s...
Show Description from GL_PERIOD where ENTER_DATE (which is in WORK view) is between FISCAL_START and FISCAL_END. Any help will be greatly appreciated.
I think you need this, I just continue your query to add the missing piece:
Here is sqlfiddle that will show you live example: fiddle example
SELECT "FisStart", "Descripton",
CASE WHEN "Entry_Date"
BETWEEN "FisStart"
AND "FisEnd"
THEN "Descripton"
ELSE 'Test Failed'
END
FROM GL_PERIOD
INNER JOIN WORK USING USING ("SrNo")
How it would be this query in Qlik Sense syntax in data loader script?
TABLA_UTIL:
SQL
SELECT "PERIODO", SUM(DEUDAFINAL) as "DEUDAFINAL"
FROM "DL_RG_ANALYTICS"."SH_PROVISION" PRO WHERE ORG='628'
GROUP BY PERIODO
concatenate
SQL
SELECT OL.PERIODO, SUM(ABIERTA/1000000)+ DEUDA/1000000
FROM "DL_RG_ANALYTICS"."SH_OTRAS_LINEAS" OL LEFT JOIN SH_SALDO_NO_IDEN_RUT PRO ON(OL.PERIODO=PRO.PERIODO)
WHERE ((ol.TIPO_DEUDA='TRASPASO' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='SAE' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='REPACTACIONES' AND ol.DEFINICION='SALDO')
OR (ol.TIPO_DEUDA='RENEGOCIADO' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='AVANCE_EFECTIVO' AND ol.DEFINICION='SALDO' ))
AND PRO.TipoTarjeta='ABIERTA'
GROUP BY OL.PERIODO, PRO.DEUDA
Any help is welcome, thanks.
Hy,
that's easy, so cheer up.
If all field names in each table are identical, Qlik Sense will set this to one immediately after the other. To make it unambiguous:
concatenate(table_name)
is a good idea.
Look at this:
qlik script guide concatenate
Here's your example:
LIB CONNECT TO 'your_database';
TABLA_UTIL:
Load *;
SQL
SELECT
"PERIODO",
SUM(DEUDAFINAL) as "DEUDAFINAL"
FROM
"DL_RG_ANALYTICS"."SH_PROVISION" PRO WHERE ORG='628'
GROUP BY PERIODO;
LIB CONNECT TO 'your_second_database'; // where necessary
concatenate(TABLA_UTIL) //all field names must be the same
Load *;
SQL
SELECT
OL.PERIODO as "PERIODO",
SUM(ABIERTA/1000000)+ DEUDA/1000000 as "DEUDAFINAL"
FROM
"DL_RG_ANALYTICS"."SH_OTRAS_LINEAS" OL LEFT JOIN SH_SALDO_NO_IDEN_RUT PRO ON(OL.PERIODO=PRO.PERIODO)
WHERE ((ol.TIPO_DEUDA='TRASPASO' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='SAE' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='REPACTACIONES' AND ol.DEFINICION='SALDO')
OR (ol.TIPO_DEUDA='RENEGOCIADO' AND ol.DEFINICION='SALDO' )
OR (ol.TIPO_DEUDA='AVANCE_EFECTIVO' AND ol.DEFINICION='SALDO' ))
AND PRO.TipoTarjeta='ABIERTA'
GROUP BY OL.PERIODO, PRO.DEUDA;
//done
Disagree with previous answer ,
Concatenate is used to concatenate tables with different fields names.
Concatenation of tables with identical set of fields is automatic and can be avoided with NOCONCATENATE keyword (before LOAD)
I have a very odd error with a report. There is one record in the record set returned to the report that is not printing on the page. When I copy the SQL statement and run it directly in SQL Server Management Studio, the row is there so I know it isn't in the selection formula. That also tells me table/view linking is correct (although I double checked that as well). I have gone through all of the grouping levels and looked at suppression settings and group sorting. Essentially, I have exhausted all options that I can find that would be causing this record to be suppressed and can't find anywhere that it would be suppressed or hidden from view. I haven't seen this behavior ever in 22 years of working with Crystal.
Any ideas of what may be causing one record to be suppressed while all others around it are still visible? I'm on version 2013, support pack 4 (14.1.4.13274). I would prefer not to rebuild this report from scratch if I can avoid it but I'm very close to the edge on this one.
Query as requested:
SELECT "KENNEL"."KENNEL_NO", "KENNEL"."ANIMAL_ID", "KENNEL"."TAG_NO", "ANIMAL"."YEARS_OLD", "ANIMAL"."MONTHS_OLD", "ANIMAL"."ANIMAL_ID", "ANIMAL"."PRIMARY_BREED", "ANIMAL"."SECONDARY_BREED", "ANIMAL"."PRIMARY_COLOR", "ANIMAL"."SECONDARY_COLOR", "ANIMAL"."ANIMAL_TYPE", "KENNEL"."OUTCOME_DATE_NULL", "v_tx_feed_sheet"."visit_type", "v_tx_feed_sheet"."resolved_date", "v_tx_feed_sheet"."visit_date", "v_tx_feed_sheet"."CONDITION_TYPE", "v_tx_feed_sheet"."TREATMENT_DESC", "dfl_kennel_groupings"."Ani_Loc_Sub", "dfl_kennel_groupings"."Ani_Loc", "KENNEL"."OUTCOME_TYPE", "KENNEL"."OUTCOME_SUBTYPE", "KENNEL"."OUTCOME_DATE", "v_tx_feed_sheet"."CYCLE", "v_tx_feed_sheet"."MEDICATION", "v_tx_feed_sheet"."NUM_DAYS", "dfl_kennel_groupings"."Offsite_Knl", "KENNEL"."INTAKE_DATE", "KENNEL"."REASON", "ANIMAL"."age_now", "ANIMAL"."DOB"
FROM (("ANIMAL"."SYSADM"."KENNEL" "KENNEL" INNER JOIN "ANIMAL"."SYSADM"."dfl_kennel_groupings" "dfl_kennel_groupings" ON "KENNEL"."KENNEL_NO"="dfl_kennel_groupings"."Kennel_No") LEFT OUTER JOIN "ANIMAL"."SYSADM"."ANIMAL" "ANIMAL" ON "KENNEL"."ANIMAL_ID"="ANIMAL"."ANIMAL_ID") LEFT OUTER JOIN "ANIMAL"."SYSADM"."v_tx_feed_sheet" "v_tx_feed_sheet" ON "KENNEL"."ANIMAL_ID"="v_tx_feed_sheet"."ANIMAL_ID"
WHERE "ANIMAL"."ANIMAL_TYPE"='DOG' AND "KENNEL"."KENNEL_NO" NOT LIKE 'DHA%' AND NOT ("KENNEL"."KENNEL_NO"='HOME' OR "KENNEL"."KENNEL_NO"='LOST') AND "KENNEL"."KENNEL_NO" LIKE 'B%' AND "dfl_kennel_groupings"."Offsite_Knl"='N' AND (("KENNEL"."OUTCOME_DATE_NULL"='Y' AND ((("v_tx_feed_sheet"."resolved_date">={ts '1899-12-30 00:00:00'} AND "v_tx_feed_sheet"."resolved_date"<{ts '1899-12-30 00:00:00'})) OR ("v_tx_feed_sheet"."resolved_date" IS NULL ))) OR ("KENNEL"."OUTCOME_DATE_NULL"='Y' AND "ANIMAL"."YEARS_OLD"=0 AND "ANIMAL"."MONTHS_OLD"<=4) OR ("ANIMAL"."ANIMAL_TYPE"='DOG' AND "KENNEL"."OUTCOME_SUBTYPE" LIKE 'SURG%' AND ("KENNEL"."OUTCOME_DATE">={ts '2017-04-26 00:00:00'} AND "KENNEL"."OUTCOME_DATE"<{ts '2017-04-27 00:00:00'})) OR ("ANIMAL"."ANIMAL_TYPE"='DOG' AND "KENNEL"."OUTCOME_SUBTYPE" LIKE 'SURG%' AND ("KENNEL"."OUTCOME_DATE">={ts '2017-04-27 00:00:00'} AND "KENNEL"."OUTCOME_DATE"<{ts '2017-04-28 00:00:00'})) OR ("ANIMAL"."ANIMAL_TYPE"='DOG' AND ("KENNEL"."INTAKE_DATE">={ts '2017-04-27 00:00:00'} AND "KENNEL"."INTAKE_DATE"<{ts '2017-04-28 00:00:00'}))) AND NOT ("KENNEL"."REASON"='DOA' OR "KENNEL"."REASON"='EUTH' OR "KENNEL"."REASON"='EUTH BEHAV' OR "KENNEL"."REASON"='EUTH ILL' OR "KENNEL"."REASON"='EUTH OLD' OR "KENNEL"."REASON"='EUTH OTHER' OR "KENNEL"."REASON"='EUTH YOUNG')
I am a newbie at CR. I have a report that someone else created. When I use the Database -> 'Show SQL Query' command the WHERE clause has a bunch of names. How can I find out where this list of names is coming from?
SELECT "billing_tx_charge_detail_2004"."date_of_service", "billing_tx_charge_detail_2004"."v_SERVICE_CODE", "billing_tx_charge_detail_2004"."v_PROVIDER_NAME", "billing_tx_charge_detail_2004"."service_status_value", "billing_tx_charge_detail_2004"."v_client_name", "billing_tx_charge_detail_2004"."guarantor_liability", "billing_tx_charge_detail_2004"."CLAIM_NUMBER", "billing_tx_charge_detail_2004"."GUARANTOR_ID", "billing_tx_charge_detail_2004"."v_service_value", "billing_tx_charge_detail_2004"."PATID", "cw_patient_notes"."service_duration", "cw_patient_notes"."note_type_value"FROM "SYSTEM"."billing_tx_charge_detail_2004" "billing_tx_charge_detail_2004" LEFT OUTER JOIN "CWSAVPMLIVESYSTEM"."cw_patient_notes" "cw_patient_notes" ON ((("billing_tx_charge_detail_2004"."FACILITY"="cw_patient_notes"."FACILITY") AND ("billing_tx_charge_detail_2004"."PATID"="cw_patient_notes"."PATID")) AND ("billing_tx_charge_detail_2004"."EPISODE_NUMBER"="cw_patient_notes"."EPISODE_NUMBER")) AND ("billing_tx_charge_detail_2004"."JOIN_TO_TX_HISTORY"="cw_patient_notes"."JOIN_TO_TX_HISTORY")
WHERE ("billing_tx_charge_detail_2004"."date_of_service">={d '2009-07-01'}
AND "billing_tx_charge_detail_2004"."date_of_service"<={d '2009-07-31'}) AND
("billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='BARNHART,SCOTT' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='BINKER,BARB MSW LISW' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='BRETNAN,BAUNEEN' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='CROWN,DWAYNE BS NCAC-I LADAC'
OR "billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='COFFEE,RAMBA BA LADAC' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='DECODE,TENISE MC LMFT LADAC' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='GONSALEZ,MAREN' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='HITAN,TOM' OR
"billing_tx_charge_detail_2004"."v_PROVIDER_NAME"='KOTUE,SHEENA')
ORDER BY "billing_tx_charge_detail_2004"."v_SERVICE_CODE",
"billing_tx_charge_detail_2004"."date_of_service", "billing_tx_charge_detail_2004"."PATID"
It is found in the Report ->Select Expert command! Hooray!
I knew as soon as I posted the question I would find the answer :)
You've got some choices. It's either:
In the record selection formula (Report > Edit Selection Formula > Record)
Hard-coded in the "Show SQL Query" window (though not as likely)
In a parameter that was either saved with the report, or contains default values (even less likely)
The following query fails to load the tables when I execute it:
IEnumerable<Bookmark> tempBookmarks = ListBookmarksByUserID(userID);
IEnumerable<CandidateWithBookmarks> results = (from c in _internshipEntities.CandidateSet
.Include("education")
.Include("progress")
.Include("contacts")
.Include("availability")
.Include("hosttypes")
.Include("hostsizes")
.Include("hostcapacities")
.Include("hoststates")
.Include("users")
join b in tempBookmarks on c.ID equals b.candidates.ID
select new CandidateWithBookmarks()
{CandidateObject = c, BookmarkObject = b});
return results;
I have found some articles related to the problem, namely Alex James' article "How to make Include really Include". The solution comes with one caveat:
For this to work your final select must be entities, i.e. select post rather than select new {…}
Which is obviously an issue for the above block of code. Are there any other known work-arounds for this issue that won't break eager loading?
I think I solved this but it might only work for this specific instance, by moving the includes after the join, the query appears to work:
IEnumerable<CandidateWithBookmarks> results = (
from b in tempBookmarks
join c in _internshipEntities.CandidateSet
.Include("education")
.Include("progress")
.Include("contacts")
.Include("availability")
.Include("hosttypes")
.Include("hostsizes")
.Include("hostcapacities")
.Include("hoststates")
.Include("users")
on b.candidates.ID equals c.ID
select new CandidateWithBookmarks(){CandidateObject = c, BookmarkObject = b});
Edit: Another query I have similar to this requires an outer join as well, which creates some issues since it then matters what you join to what, unlike this example, but it's still doable.