Get All Tickets in OSticket - mysql

Can someone help me figure out how I can retrieve all tickets? I read online and saw that there's no API to do this yet? I also read that i can write some sql code to retrieve them?
My objective is: Check OSticket to see if the ticket with the same subject is created more than 3 times, then to basically alert me ( for now it can just be a message in Powershell that says it, as I'm scripting in PS).
For that I need to retrieve all tickets in the OSticketDB. Since I just have it locally for now, I have a sql DB setup but I don't see something along the lines of ost_tickets? Not sure how I can retrieve tickets that have been duplicates from same subject.

I'm not sure I understand your question correctly. But here is SQL query, that will return all tickets, where subject has occurred more than 3 times.
SELECT
cdata.ticket_id,
cdata.subject,
ticket.number,
subjectstable.subjectcount
FROM
osticketdb.ost_ticket AS ticket
INNER JOIN osticketdb.ost_ticket__cdata AS cdata ON ticket.ticket_id = cdata.ticket_id
INNER JOIN
(SELECT subject, COUNT(*) as subjectcount FROM osticketdb.ost_ticket__cdata GROUP BY subject) AS subjectstable
ON subjectstable.subject = cdata.subject
WHERE subjectstable.subjectcount > 3

Related

SSRS - Trying to find all User Reports tied to a Batch File / Subscriptions

I have tried various queries I have found to try and accomplish this and none of them seem to list all the batch file/subscription instances tied to a user report in SSRS. If there is already a batch file out there tied to a user report, that's what I want to use versus creating a new batch file. I have tried going through the tables in the ReportServer database and looking for records to link to try and find this information, but I have been unsuccessful. Sorry if this is a simplistic question, but I have spent a few days trying to figure this out. Thank you!
You should be able to get at all subscriptions on your report server by running the following query:
You can alter this to suit your needs
use [ReportServer]
SELECT
R.Name
, L.TimeDataRetrieval
,L.TimeProcessing
,L.TimeRendering
, L.TimeDataRetrieval+L.TimeProcessing+L.TimeRendering AS TotalTime
,L.Format
,L.[Parameters]
,L.username
,L.TimeStart
,L.TimeEnd
,l.ReportID
,DATEDIFF(SECOND,L.timestart,L.timeend) time_seconds
,r.Path
FROM dbo.ExecutionLog L
INNER JOIN dbo.Catalog R
ON L.ReportID = R.ItemID
WHERE
R.Name like 'name of your report'

I can't find a way to implement messages in my school database on MySQL

I'm working on a school database on which I would like to implement messages that will be created by the schools for the parents to view.
The workflow goes like this:
1. The school sends a message to a certain group of students, it could be a message to all the students from that school, or a message to just the first year, or a message to classroom 1B (1 being the year and B the group), or even a message to just 1 student.
2. Parents access a platform on which they will see the messages regarding their children.
For example:
if the school sends a message to the classroom 1B, only parents with children on that classroom will be able to see it.
if the school sends a message to the first year, only parents with
children on the first year will see it.
What I need help with is:
How could I arrange the database in order to accomplish the message
filtering (By school, by year, by classroom (1B, 2A,
etc.) and by student)?
What would be the sentence that I need to use in order to retrieve
the messages for a parent regarding their children?
I hope I explained myself well, please feel free to ask any question you have, and thank you so much :)
Here's a pic of the database:
If I understood well, for this question "What would be the sentence that I need to use in order to retrieve the messages for a parent regarding their children?" you could use a simple inner join between message and parent_detail on id_students are equals where id_parent is your parentID:
SELECT * FROM `message` m
INNER JOIN `parent_detail` p_d on p_d.ID_student = m.ID_student
WHERE p_d.ID_detail = 'parent_id_variable'
Regarding the first question, using the same principle, you need to use an inner join between message students and schools (if you want the name of the school and not only the ID) and apply in where condition what parameter you want.
For example, by school => message.ID_school, by school and by year => message.ID_school and students.year.

inner query of subqery returning multiple rows

I am not that experience in sql so please forgive if its not a good question to ask,but i researched around almost for 3-4 days but no able to solve.
My problem is i have a table which have multiple image names in it,so what i have to do is whoever is the follower of a particular user i have to get the imaged from this table,so one user there can be multiple followers,so i have to fetch the images posted by all the followers.
Here is the subquery code snippet i am using.
SELECT id,
outfit_image,
img_title,
description
FROM outfitpic_list r2
WHERE Email=ANY(SELECT being_followed
FROM follower_table
WHERE follower='test#gmail.com')
So the inner query here returns multiple values,for each value(being_followed) i have to fetch all the images and display it,but with this query each time i get only one image.I tried IN also but didnot work out.
Table structure:-
Outfitpic_list table
id|outfit_image|datetime|Email|image_title|description
Follower_table
bring_followed|follower
Please help,I am stuck..!!
Thank you..!!
I think your problem may be the = sign between "E-mail" and "Any". Try this statement:
SELECT
id,
outfit_image,
img_title,
description
FROM outfitpic_list r2
WHERE Email IN
(
SELECT being_followed
FROM follower_table
WHERE follower='test#gmail.com'
)
It's the same statement, without the = sign, and the ANY keyword replaced with IN. (I cleaned it up a little to make it more readable)

How can I see full order details for each time a certain coupon code was used in magento?

We are trying to collect data on each person that used a certain coupon code "NEWCUSTOMER". We are trying to get the order details including their name, email address, and what they ordered.
Is the rule_id connected to an order in any way in the database? The magento databases don't seem to be all that friendly when you are trying to write your own mySQL statement to figure this information out.
Thanks!
This is similar to your previous question which i have also answered for you: Find the name and email address of non-members who used coupon code in Magento
The coupon code used on an order is actually a property of the order: coupon_code
It sounds from your question that you are directly querying the db, if so then you are looking for the coupon_code field in the sales_flat_order table.
Here is the sql:
SELECT `customer_firstname`, `customer_lastname`, `customer_email` FROM `sales_flat_order` WHERE `coupon_code` = 'your_awesome_coupon_code' AND `customer_group_id` = 0
Or, via magento...
$orderCollection = Mage::getModel('sales/order')->getCollection()
->addAttributeToSelect('customer_firstname')
->addAttributeToSelect('customer_lastname')
->addAttributeToSelect('customer_email')
->addAttributeToSelect('customer_group_id')
->addAttributeToSelect('coupon_code')
->addAttributeToFilter('customer_group_id', Mage_Customer_Model_Group::NOT_LOGGED_IN_ID)
->addAttributeToFilter('coupon_code', 'NEWCUSTOMER');

Need help on using SQL Query in Crystal Reports on Vb.NET 2010

I'm using MySQL with Vb.Net 2010 and Crystal Reports and to be honest I'm a complete noob when it comes to using Sql Queries. The problem is, I want to generate a report that will show the service fee from a transaction a person made while also showing the items bought, and their quantity and prices, basically a bill. I created a command from the data source I created in crystal reports and it contains this query:
SELECT t.transaction_code,t.fee,t.service_type,t.date_sched,total_bill, s.item_code, s.quantity_sold, i.item_description, i.price, CONCAT(p.fname,' ',p.mi,' ',p.lname),p.address FROM tbl_transaction AS t, tbl_sale AS s, tbl_item AS i, tbl_profile as p WHERE t.transaction_code = '{?trans_code}' AND s.transaction_code = t.transaction_code AND i.item_code = s.item_code AND p.id='{?p_id}'
It all works fine if I use that, the report shows everything like the persons name, transaction code, service type and its fee as well as all the items bought and the total bill. The problem is, if in that certain transaction, the said person only required services and did not buy any items, the report will just be blank. What I want is that the report should still be able to display the person's name, transaction code, service type and its fee, etc., even without buying an item. I know it's kind of hard to understand and it's also hard for me to explain, but I really need help right now.
Since I can't post images yet since I'm a new user. I'll just post a link to where I uploaded the structures of my tables:
http://oi42.tinypic.com/xogw9k.jpg
I also have a table called link_profile_transaction which does what it says and another table for the services which is linked to the services and fee from the transaction table(tbl_transaction) though it isn't included in the query.
http://oi41.tinypic.com/fqm2b.jpg
The links are legit and safe.
You must left join the items table to the service table.
Not really certain about the schema of your table, I am providing below for you to edit if it does not work as is.
SELECT t.transaction_code,t.fee,t.service_type,… s.item_code, s.quantity_sold,
i.item_description, i.price, CONCAT(p.fname,' ',p.mi,' ',p.lname),p.address
FROM tbl_transaction AS t, tbl_sale AS s, tbl_profile as p
LEFT JOIN tbl_item AS i ON i.item_code = s.item_code
WHERE t.transaction_code = '{?trans_code}'
AND s.transaction_code = t.transaction_code AND
p.id='{?p_id}'