CR XI
Oracle db
SQL syntax experience = weak
Crystal syntax experience = competent
I am trying to write a SQL Command with a union to combine a two similar fields from two tables. I need both fields in one table for my report. The field is called charge (which contains various arrest charge codes applied to a person in police custody). I have listed the fields I will need to use in my report.
TABLE-1 is called INBOK6
Fields:
"INBOK6_VIEW"."PRN", PRIMARY KEY FIELD (one charge per PRN)
"INBOK6_VIEW"."Level",
"INBOK6_VIEW"."Warrant_No",
"INBOK6_VIEW"."Arrest_Date",
"INBOK6_VIEW"."Booking_No",
"INBOK6_VIEW"."Charge"
TABLE-2 is called INACG6
"INACG6_VIEW"."PRN", CHILD FIELD (0 to many charges per PRN)
"INACG6_VIEW"."Level",
"INACG6_VIEW"."Warrant_No",
"INACG6_VIEW"."Charge"
I need a left outer join from "INBOK6_VIEW"."PRN" to "INACG6_VIEW"."PRN"
Here's where I started, but I am confused on how to properly set up the SQL script for left outer join and if I have my fields set up on the proper side of the union.
SELECT 'CHARGE1' as whichcharge,
" INBOK6_VIEW"."Level",
" INBOK6_VIEW"."Warrant_No",
" INBOK6_VIEW"."Arrest_Date",
"INBOK6_VIEW"."PRN",
" INBOK6_VIEW"."Booking_No",
" INBOK6_VIEW"."Charge" as CHARGE
FROM "PDDB"."INBOK6_VIEW" " INBOK6_VIEW" LEFT OUTER JOIN "PDDB"."INACG6_VIEW" "INACG6_VIEW" ON "INBOK6_VIEW"."PRN"="INACG6_VIEW"."PRN"
UNION
SELECT
'CHARGE2' as whichcharge,
" INACG6_VIEW"."PRN",
" INACG6_VIEW"."Level",
" INACG6_VIEW"."Warrant_No",
" INACG6_VIEW"."Charge" as CHARGE
FROM "PDDB"."INBOK6_VIEW" " INBOK6_VIEW" LEFT OUTER JOIN "PDDB"."GAPD_INACG6_VIEW" "INACG6_VIEW" ON "INBOK6_VIEW"."PRN"="INACG6_VIEW"."PRN"
Here's one of the errors I get:
FROM KEYWORD NOT FOUND WHERE EXPECTED
Oracle db
SQL syntax experience = weak
Crystal syntax experience = competent
I am trying to write a SQL Command with a union to combine a two similar fields from two tables. I need both fields in one table for my report. The field is called charge (which contains various arrest charge codes applied to a person in police custody). I have listed the fields I will need to use in my report.
TABLE-1 is called INBOK6
Fields:
"INBOK6_VIEW"."PRN", PRIMARY KEY FIELD (one charge per PRN)
"INBOK6_VIEW"."Level",
"INBOK6_VIEW"."Warrant_No",
"INBOK6_VIEW"."Arrest_Date",
"INBOK6_VIEW"."Booking_No",
"INBOK6_VIEW"."Charge"
TABLE-2 is called INACG6
"INACG6_VIEW"."PRN", CHILD FIELD (0 to many charges per PRN)
"INACG6_VIEW"."Level",
"INACG6_VIEW"."Warrant_No",
"INACG6_VIEW"."Charge"
I need a left outer join from "INBOK6_VIEW"."PRN" to "INACG6_VIEW"."PRN"
Here's where I started, but I am confused on how to properly set up the SQL script for left outer join and if I have my fields set up on the proper side of the union.
SELECT 'CHARGE1' as whichcharge,
" INBOK6_VIEW"."Level",
" INBOK6_VIEW"."Warrant_No",
" INBOK6_VIEW"."Arrest_Date",
"INBOK6_VIEW"."PRN",
" INBOK6_VIEW"."Booking_No",
" INBOK6_VIEW"."Charge" as CHARGE
FROM "PDDB"."INBOK6_VIEW" " INBOK6_VIEW" LEFT OUTER JOIN "PDDB"."INACG6_VIEW" "INACG6_VIEW" ON "INBOK6_VIEW"."PRN"="INACG6_VIEW"."PRN"
UNION
SELECT
'CHARGE2' as whichcharge,
" INACG6_VIEW"."PRN",
" INACG6_VIEW"."Level",
" INACG6_VIEW"."Warrant_No",
" INACG6_VIEW"."Charge" as CHARGE
FROM "PDDB"."INBOK6_VIEW" " INBOK6_VIEW" LEFT OUTER JOIN "PDDB"."GAPD_INACG6_VIEW" "INACG6_VIEW" ON "INBOK6_VIEW"."PRN"="INACG6_VIEW"."PRN"
Here's one of the errors I get:
FROM KEYWORD NOT FOUND WHERE EXPECTED